Annotation of htdocs/docs/pkgsrc/pkgsrc.html, revision 1.14
1.1 dsieger 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2: <html>
3: <head>
4: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
5: <title>The pkgsrc guide</title>
1.2 rillig 6: <link rel="stylesheet" href="/global.css" type="text/css">
1.1 dsieger 7: <meta name="generator" content="DocBook XSL Stylesheets VX.X.X">
8: <meta name="description" content="pkgsrc is a centralized package management system for Unix-like operating systems. This guide provides information for users and developers of pkgsrc. It covers installation of binary and source packages, creation of binary and source packages and a high-level overview about the infrastructure.">
9: </head>
10: <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" lang="en">
11: <div class="titlepage">
12: <div>
13: <div><h1 class="title">
14: <a name="the-pkgsrc-guide"></a>The pkgsrc guide</h1></div>
15: <div><h2 class="subtitle">Documentation on the NetBSD packages system</h2></div>
16: <div><div class="authorgroup">
17: <div class="author">
18: <h3 class="author">
19: <span class="firstname">Alistair</span> <span class="surname">Crooks</span>
20: </h3>
1.10 hubertf 21: <div class="affiliation"><div class="address"><p><code class="email"><<a class="email" href="mailto:agc@NetBSD.org">agc@NetBSD.org</a>></code></p></div></div>
1.1 dsieger 22: </div>
23: <div class="author">
24: <h3 class="author">
25: <span class="firstname">Hubert</span> <span class="surname">Feyrer</span>
26: </h3>
1.10 hubertf 27: <div class="affiliation"><div class="address"><p><code class="email"><<a class="email" href="mailto:hubertf@NetBSD.org">hubertf@NetBSD.org</a>></code></p></div></div>
1.1 dsieger 28: </div>
29: <h3 class="corpauthor">
30: The pkgsrc Developers
31: </h3>
32: </div></div>
1.4 rillig 33: <div><p class="copyright">Copyright © 1994-2007 The NetBSD Foundation, Inc</p></div>
1.6 rillig 34: <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.26 2007/09/18 08:17:21 rillig Exp $</p></div>
1.1 dsieger 35: <div><div class="abstract">
36: <p class="title"><b>Abstract</b></p>
37: <p>pkgsrc is a centralized package management system for
38: Unix-like operating systems. This guide provides information for
39: users and developers of pkgsrc. It covers installation of binary
40: and source packages, creation of binary and source packages and
41: a high-level overview about the infrastructure.</p>
42: </div></div>
43: </div>
44: <hr>
45: </div>
46: <div class="toc">
47: <p><b>Table of Contents</b></p>
48: <dl>
49: <dt><span class="chapter"><a href="#introduction">1. What is pkgsrc?</a></span></dt>
50: <dd><dl>
51: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
52: <dd><dl>
53: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
54: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
55: </dl></dd>
56: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
57: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
58: <dd><dl><dt><span class="sect2"><a href="#term.roles">1.3.1. Roles involved in pkgsrc</a></span></dt></dl></dd>
59: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
60: </dl></dd>
61: <dt><span class="part"><a href="#users-guide">I. The pkgsrc user's guide</a></span></dt>
62: <dd><dl>
63: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
64: <dd><dl>
65: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
66: <dd><dl>
67: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
68: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
69: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via anonymous CVS</a></span></dt>
70: </dl></dd>
71: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
72: <dd><dl>
73: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
74: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
75: </dl></dd>
76: </dl></dd>
77: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
78: <dd><dl>
79: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
80: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
81: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
82: <dd><dl>
83: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
84: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
85: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
86: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
87: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
88: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
89: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
90: </dl></dd>
91: </dl></dd>
92: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
93: <dd><dl>
94: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
95: <dd><dl>
96: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
97: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
98: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
99: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
100: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
101: <dt><span class="sect2"><a href="#pkg_versions">4.1.6. Finding if newer versions of your installed packages are in pkgsrc</a></span></dt>
102: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
103: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
104: </dl></dd>
105: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
106: <dd><dl>
107: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
108: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
109: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
110: </dl></dd>
111: </dl></dd>
112: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
113: <dd><dl>
114: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
115: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.9 rillig 116: <dt><span class="sect1"><a href="#variables-affecting-installation">5.3. Variables affecting the installation process</a></span></dt>
1.4 rillig 117: <dt><span class="sect1"><a href="#conf.compiler">5.4. Selecting and configuring the compiler</a></span></dt>
1.1 dsieger 118: <dd><dl>
1.4 rillig 119: <dt><span class="sect2"><a href="#selecting-the-compiler">5.4.1. Selecting the compiler</a></span></dt>
120: <dt><span class="sect2"><a href="#conf.cflags">5.4.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
121: <dt><span class="sect2"><a href="#conf.ldflags">5.4.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
1.1 dsieger 122: </dl></dd>
1.4 rillig 123: <dt><span class="sect1"><a href="#developer-advanced-settings">5.5. Developer/advanced settings</a></span></dt>
124: <dt><span class="sect1"><a href="#selecting-build-options">5.6. Selecting Build Options</a></span></dt>
1.1 dsieger 125: </dl></dd>
126: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
127: <dd><dl>
128: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
129: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
1.6 rillig 130: </dl></dd>
131: <dt><span class="chapter"><a href="#bulk">7. Creating binary packages for everything in pkgsrc (bulk
132: builds)</a></span></dt>
1.1 dsieger 133: <dd><dl>
1.6 rillig 134: <dt><span class="sect1"><a href="#bulk.pre">7.1. Think first, build later</a></span></dt>
135: <dt><span class="sect1"><a href="#bulk.req">7.2. Requirements of a bulk build</a></span></dt>
136: <dt><span class="sect1"><a href="#bulk.old">7.3. Running an old-style bulk build</a></span></dt>
137: <dd><dl>
138: <dt><span class="sect2"><a href="#binary.configuration">7.3.1. Configuration</a></span></dt>
139: <dt><span class="sect2"><a href="#other-environmental-considerations">7.3.2. Other environmental considerations</a></span></dt>
140: <dt><span class="sect2"><a href="#operation">7.3.3. Operation</a></span></dt>
141: <dt><span class="sect2"><a href="#what-it-does">7.3.4. What it does</a></span></dt>
142: <dt><span class="sect2"><a href="#disk-space-requirements">7.3.5. Disk space requirements</a></span></dt>
143: <dt><span class="sect2"><a href="#setting-up-a-sandbox">7.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
144: <dt><span class="sect2"><a href="#building-a-partial-set">7.3.7. Building a partial set of packages</a></span></dt>
145: <dt><span class="sect2"><a href="#bulk-upload">7.3.8. Uploading results of a bulk build</a></span></dt>
146: </dl></dd>
147: <dt><span class="sect1"><a href="#bulk.pbulk">7.4. Running a pbulk-style bulk build</a></span></dt>
148: <dd><dl><dt><span class="sect2"><a href="#bulk.pbulk.conf">7.4.1. Configuration</a></span></dt></dl></dd>
149: <dt><span class="sect1"><a href="#creating-cdroms">7.5. Creating a multiple CD-ROM packages collection</a></span></dt>
150: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">7.5.1. Example of cdpack</a></span></dt></dl></dd>
151: </dl></dd>
152: <dt><span class="chapter"><a href="#files">8. Directory layout of the installed files</a></span></dt>
153: <dd><dl>
154: <dt><span class="sect1"><a href="#files.localbase">8.1. File system layout in <code class="literal">${LOCALBASE}</code></a></span></dt>
155: <dt><span class="sect1"><a href="#files.varbase">8.2. File system layout in <code class="literal">${VARBASE}</code></a></span></dt>
156: </dl></dd>
157: <dt><span class="chapter"><a href="#faq">9. Frequently Asked Questions</a></span></dt>
158: <dd><dl>
159: <dt><span class="sect1"><a href="#mailing-list-pointers">9.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
160: <dt><span class="sect1"><a href="#pkgviews-docs">9.2. Where's the pkgviews documentation?</a></span></dt>
161: <dt><span class="sect1"><a href="#faq-pkgtools">9.3. Utilities for package management (pkgtools)</a></span></dt>
162: <dt><span class="sect1"><a href="#non-root-pkgsrc">9.4. How to use pkgsrc as non-root</a></span></dt>
163: <dt><span class="sect1"><a href="#resume-transfers">9.5. How to resume transfers when fetching distfiles?</a></span></dt>
164: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">9.6. How can I install/use modular X.org from pkgsrc?</a></span></dt>
165: <dt><span class="sect1"><a href="#fetch-behind-firewall">9.7. How to fetch files from behind a firewall</a></span></dt>
1.10 hubertf 166: <dt><span class="sect1"><a href="#passive-ftp">9.8. How do I tell <span class="command"><strong>make fetch</strong></span> to do passive FTP?</a></span></dt>
1.6 rillig 167: <dt><span class="sect1"><a href="#fetching-all-distfiles">9.9. How to fetch all distfiles at once</a></span></dt>
168: <dt><span class="sect1"><a href="#tmac.andoc-missing">9.10. What does “<span class="quote">Don't know how to make
1.1 dsieger 169: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
1.6 rillig 170: <dt><span class="sect1"><a href="#bsd.own.mk-missing">9.11. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</a></span></dt>
171: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">9.12. Using 'sudo' with pkgsrc</a></span></dt>
172: <dt><span class="sect1"><a href="#faq.conf">9.13. How do I change the location of configuration files?</a></span></dt>
173: <dt><span class="sect1"><a href="#audit-packages">9.14. Automated security checks</a></span></dt>
174: <dt><span class="sect1"><a href="#ufaq-cflags">9.15. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
175: <dt><span class="sect1"><a href="#ufaq-fail">9.16. A package does not build. What shall I do?</a></span></dt>
176: <dt><span class="sect1"><a href="#faq.rcs-conflicts">9.17. What does “<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>” mean?</a></span></dt>
1.1 dsieger 177: </dl></dd>
178: </dl></dd>
179: <dt><span class="part"><a href="#developers-guide">II. The pkgsrc developer's guide</a></span></dt>
180: <dd><dl>
1.6 rillig 181: <dt><span class="chapter"><a href="#creating">10. Creating a new pkgsrc package from scratch</a></span></dt>
1.1 dsieger 182: <dd><dl>
1.6 rillig 183: <dt><span class="sect1"><a href="#creating.common">10.1. Common types of packages</a></span></dt>
1.1 dsieger 184: <dd><dl>
1.6 rillig 185: <dt><span class="sect2"><a href="#creating.perl-module">10.1.1. Perl modules</a></span></dt>
186: <dt><span class="sect2"><a href="#creating.kde-app">10.1.2. KDE applications</a></span></dt>
1.1 dsieger 187: </dl></dd>
1.6 rillig 188: <dt><span class="sect1"><a href="#creating.examples">10.2. Examples</a></span></dt>
189: <dd><dl><dt><span class="sect2"><a href="#creating.nvu">10.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd>
190: </dl></dd>
191: <dt><span class="chapter"><a href="#components">11. Package components - files, directories and contents</a></span></dt>
192: <dd><dl>
193: <dt><span class="sect1"><a href="#components.Makefile">11.1. <code class="filename">Makefile</code></a></span></dt>
194: <dt><span class="sect1"><a href="#components.distinfo">11.2. <code class="filename">distinfo</code></a></span></dt>
195: <dt><span class="sect1"><a href="#components.patches">11.3. patches/*</a></span></dt>
196: <dd><dl>
197: <dt><span class="sect2"><a href="#components.patch.structure">11.3.1. Structure of a single patch file</a></span></dt>
198: <dt><span class="sect2"><a href="#components.patches.caveats">11.3.2. Creating patch files</a></span></dt>
199: <dt><span class="sect2"><a href="#components.patches.sources">11.3.3. Sources where the patch files come from</a></span></dt>
200: <dt><span class="sect2"><a href="#components.patches.guidelines">11.3.4. Patching guidelines</a></span></dt>
201: <dt><span class="sect2"><a href="#components.patches.feedback">11.3.5. Feedback to the author</a></span></dt>
202: </dl></dd>
203: <dt><span class="sect1"><a href="#other-mandatory-files">11.4. Other mandatory files</a></span></dt>
204: <dt><span class="sect1"><a href="#components.optional">11.5. Optional files</a></span></dt>
205: <dd><dl>
206: <dt><span class="sect2"><a href="#components.optional.bin">11.5.1. Files affecting the binary package</a></span></dt>
207: <dt><span class="sect2"><a href="#components.optional.build">11.5.2. Files affecting the build process</a></span></dt>
208: <dt><span class="sect2"><a href="#components.optional.none">11.5.3. Files affecting nothing at all</a></span></dt>
209: </dl></dd>
210: <dt><span class="sect1"><a href="#work-dir">11.6. <code class="filename">work*</code></a></span></dt>
211: <dt><span class="sect1"><a href="#files-dir">11.7. <code class="filename">files/*</code></a></span></dt>
212: </dl></dd>
213: <dt><span class="chapter"><a href="#makefile">12. Programming in <code class="filename">Makefile</code>s</a></span></dt>
214: <dd><dl>
215: <dt><span class="sect1"><a href="#makefile.style">12.1. Caveats</a></span></dt>
216: <dt><span class="sect1"><a href="#makefile.variables">12.2. <code class="filename">Makefile</code> variables</a></span></dt>
217: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">12.2.1. Naming conventions</a></span></dt></dl></dd>
218: <dt><span class="sect1"><a href="#makefile.code">12.3. Code snippets</a></span></dt>
219: <dd><dl>
220: <dt><span class="sect2"><a href="#adding-to-list">12.3.1. Adding things to a list</a></span></dt>
221: <dt><span class="sect2"><a href="#converting-internal-to-external">12.3.2. Converting an internal list into an external list</a></span></dt>
222: <dt><span class="sect2"><a href="#passing-variable-to-shell">12.3.3. Passing variables to a shell command</a></span></dt>
223: <dt><span class="sect2"><a href="#quoting-guideline">12.3.4. Quoting guideline</a></span></dt>
224: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">12.3.5. Workaround for a bug in BSD Make</a></span></dt>
225: </dl></dd>
226: </dl></dd>
227: <dt><span class="chapter"><a href="#plist">13. PLIST issues</a></span></dt>
228: <dd><dl>
229: <dt><span class="sect1"><a href="#rcs-id">13.1. RCS ID</a></span></dt>
230: <dt><span class="sect1"><a href="#automatic-plist-generation">13.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
1.10 hubertf 231: <dt><span class="sect1"><a href="#print-PLIST">13.3. Tweaking output of <span class="command"><strong>make print-PLIST</strong></span></a></span></dt>
1.6 rillig 232: <dt><span class="sect1"><a href="#plist.misc">13.4. Variable substitution in PLIST</a></span></dt>
233: <dt><span class="sect1"><a href="#manpage-compression">13.5. Man page compression</a></span></dt>
234: <dt><span class="sect1"><a href="#using-PLIST_SRC">13.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
235: <dt><span class="sect1"><a href="#platform-specific-plist">13.7. Platform-specific and differing PLISTs</a></span></dt>
236: <dt><span class="sect1"><a href="#faq.common-dirs">13.8. Sharing directories between packages</a></span></dt>
237: </dl></dd>
238: <dt><span class="chapter"><a href="#buildlink">14. Buildlink methodology</a></span></dt>
239: <dd><dl>
240: <dt><span class="sect1"><a href="#converting-to-buildlink3">14.1. Converting packages to use buildlink3</a></span></dt>
241: <dt><span class="sect1"><a href="#creating-buildlink3.mk">14.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
242: <dd><dl>
243: <dt><span class="sect2"><a href="#anatomy-of-bl3">14.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
244: <dt><span class="sect2"><a href="#updating-buildlink-depends">14.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>
245: </dl></dd>
246: <dt><span class="sect1"><a href="#writing-builtin.mk">14.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
247: <dd><dl>
248: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">14.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
249: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">14.3.2. Global preferences for native or pkgsrc software</a></span></dt>
250: </dl></dd>
251: </dl></dd>
252: <dt><span class="chapter"><a href="#pkginstall">15. The pkginstall framework</a></span></dt>
253: <dd><dl>
254: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">15.1. Files and directories outside the installation prefix</a></span></dt>
255: <dd><dl>
256: <dt><span class="sect2"><a href="#dirs-outside-prefix">15.1.1. Directory manipulation</a></span></dt>
257: <dt><span class="sect2"><a href="#files-outside-prefix">15.1.2. File manipulation</a></span></dt>
258: </dl></dd>
259: <dt><span class="sect1"><a href="#conf-files">15.2. Configuration files</a></span></dt>
260: <dd><dl>
261: <dt><span class="sect2"><a href="#conf-files-sysconfdir">15.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
262: <dt><span class="sect2"><a href="#conf-files-configure">15.2.2. Telling the software where configuration files are</a></span></dt>
263: <dt><span class="sect2"><a href="#conf-files-patching">15.2.3. Patching installations</a></span></dt>
264: <dt><span class="sect2"><a href="#conf-files-disable">15.2.4. Disabling handling of configuration files</a></span></dt>
265: </dl></dd>
266: <dt><span class="sect1"><a href="#rcd-scripts">15.3. System startup scripts</a></span></dt>
267: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">15.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
268: <dt><span class="sect1"><a href="#users-and-groups">15.4. System users and groups</a></span></dt>
269: <dt><span class="sect1"><a href="#shells">15.5. System shells</a></span></dt>
270: <dd><dl><dt><span class="sect2"><a href="#shells-disable">15.5.1. Disabling shell registration</a></span></dt></dl></dd>
271: <dt><span class="sect1"><a href="#fonts">15.6. Fonts</a></span></dt>
272: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">15.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
273: </dl></dd>
274: <dt><span class="chapter"><a href="#options">16. Options handling</a></span></dt>
275: <dd><dl>
276: <dt><span class="sect1"><a href="#global-default-options">16.1. Global default options</a></span></dt>
277: <dt><span class="sect1"><a href="#converting-to-options">16.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
278: <dt><span class="sect1"><a href="#option-names">16.3. Option Names</a></span></dt>
1.7 rillig 279: <dt><span class="sect1"><a href="#option-build">16.4. Determining the options of dependencies</a></span></dt>
1.6 rillig 280: </dl></dd>
281: <dt><span class="chapter"><a href="#build">17. The build process</a></span></dt>
282: <dd><dl>
283: <dt><span class="sect1"><a href="#build.intro">17.1. Introduction</a></span></dt>
284: <dt><span class="sect1"><a href="#build.prefix">17.2. Program location</a></span></dt>
285: <dt><span class="sect1"><a href="#build.builddirs">17.3. Directories used during the build process</a></span></dt>
286: <dt><span class="sect1"><a href="#build.running">17.4. Running a phase</a></span></dt>
287: <dt><span class="sect1"><a href="#build.fetch">17.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
288: <dd><dl>
289: <dt><span class="sect2"><a href="#build.fetch.what">17.5.1. What to fetch and where to get it from</a></span></dt>
290: <dt><span class="sect2"><a href="#build.fetch.how">17.5.2. How are the files fetched?</a></span></dt>
291: </dl></dd>
292: <dt><span class="sect1"><a href="#build.checksum">17.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
293: <dt><span class="sect1"><a href="#build.extract">17.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
294: <dt><span class="sect1"><a href="#build.patch">17.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
295: <dt><span class="sect1"><a href="#build.tools">17.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
296: <dt><span class="sect1"><a href="#build.wrapper">17.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
297: <dt><span class="sect1"><a href="#build.configure">17.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
298: <dt><span class="sect1"><a href="#build.build">17.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
299: <dt><span class="sect1"><a href="#build.test">17.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
300: <dt><span class="sect1"><a href="#build.install">17.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
301: <dt><span class="sect1"><a href="#build.package">17.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
302: <dt><span class="sect1"><a href="#build.clean">17.16. Cleaning up</a></span></dt>
303: <dt><span class="sect1"><a href="#build.helpful-targets">17.17. Other helpful targets</a></span></dt>
304: </dl></dd>
305: <dt><span class="chapter"><a href="#tools">18. Tools needed for building or running</a></span></dt>
306: <dd><dl>
307: <dt><span class="sect1"><a href="#pkgsrc-tools">18.1. Tools for pkgsrc builds</a></span></dt>
308: <dt><span class="sect1"><a href="#package-tools">18.2. Tools needed by packages</a></span></dt>
309: <dt><span class="sect1"><a href="#platform-tools">18.3. Tools provided by platforms</a></span></dt>
310: <dt><span class="sect1"><a href="#tools.questions">18.4. Questions regarding the tools</a></span></dt>
311: </dl></dd>
312: <dt><span class="chapter"><a href="#fixes">19. Making your package work</a></span></dt>
313: <dd><dl>
314: <dt><span class="sect1"><a href="#general-operation">19.1. General operation</a></span></dt>
315: <dd><dl>
316: <dt><span class="sect2"><a href="#portability-of-packages">19.1.1. Portability of packages</a></span></dt>
317: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">19.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
318: <dt><span class="sect2"><a href="#user-interaction">19.1.3. User interaction</a></span></dt>
319: <dt><span class="sect2"><a href="#handling-licenses">19.1.4. Handling licenses</a></span></dt>
320: <dt><span class="sect2"><a href="#restricted-packages">19.1.5. Restricted packages</a></span></dt>
321: <dt><span class="sect2"><a href="#dependencies">19.1.6. Handling dependencies</a></span></dt>
322: <dt><span class="sect2"><a href="#conflicts">19.1.7. Handling conflicts with other packages</a></span></dt>
323: <dt><span class="sect2"><a href="#not-building-packages">19.1.8. Packages that cannot or should not be built</a></span></dt>
324: <dt><span class="sect2"><a href="#undeletable-packages">19.1.9. Packages which should not be deleted, once installed</a></span></dt>
325: <dt><span class="sect2"><a href="#security-handling">19.1.10. Handling packages with security problems</a></span></dt>
326: <dt><span class="sect2"><a href="#bumping-pkgrevision">19.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
327: <dt><span class="sect2"><a href="#fixes.subst">19.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
328: </dl></dd>
329: <dt><span class="sect1"><a href="#fixes.fetch">19.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
330: <dd><dl>
331: <dt><span class="sect2"><a href="#no-plain-download">19.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
332: <dt><span class="sect2"><a href="#modified-distfiles-same-name">19.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
333: </dl></dd>
334: <dt><span class="sect1"><a href="#fixes.configure">19.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
335: <dd><dl>
336: <dt><span class="sect2"><a href="#fixes.libtool">19.3.1. Shared libraries - libtool</a></span></dt>
337: <dt><span class="sect2"><a href="#using-libtool">19.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
338: <dt><span class="sect2"><a href="#autoconf-automake">19.3.3. GNU Autoconf/Automake</a></span></dt>
339: </dl></dd>
340: <dt><span class="sect1"><a href="#programming-languages">19.4. Programming languages</a></span></dt>
341: <dd><dl>
342: <dt><span class="sect2"><a href="#basic-programming-languages">19.4.1. C, C++, and Fortran</a></span></dt>
343: <dt><span class="sect2"><a href="#java-programming-language">19.4.2. Java</a></span></dt>
344: <dt><span class="sect2"><a href="#perl-scripts">19.4.3. Packages containing perl scripts</a></span></dt>
345: <dt><span class="sect2"><a href="#other-programming-languages">19.4.4. Other programming languages</a></span></dt>
346: </dl></dd>
347: <dt><span class="sect1"><a href="#fixes.build">19.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
348: <dd><dl>
349: <dt><span class="sect2"><a href="#fixes.build.cpp">19.5.1. Compiling C and C++ code conditionally</a></span></dt>
350: <dt><span class="sect2"><a href="#compiler-bugs">19.5.2. How to handle compiler bugs</a></span></dt>
351: <dt><span class="sect2"><a href="#undefined-reference">19.5.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
352: <dt><span class="sect2"><a href="#out-of-memory">19.5.4. Running out of memory</a></span></dt>
353: </dl></dd>
354: <dt><span class="sect1"><a href="#fixes.install">19.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
355: <dd><dl>
356: <dt><span class="sect2"><a href="#install-scripts">19.6.1. Creating needed directories</a></span></dt>
357: <dt><span class="sect2"><a href="#where-to-install-documentation">19.6.2. Where to install documentation</a></span></dt>
358: <dt><span class="sect2"><a href="#installing-score-files">19.6.3. Installing highscore files</a></span></dt>
359: <dt><span class="sect2"><a href="#destdir-support">19.6.4. Adding DESTDIR support to packages</a></span></dt>
360: <dt><span class="sect2"><a href="#hardcoded-paths">19.6.5. Packages with hardcoded paths to other interpreters</a></span></dt>
361: <dt><span class="sect2"><a href="#perl-modules">19.6.6. Packages installing perl modules</a></span></dt>
362: <dt><span class="sect2"><a href="#faq.info-files">19.6.7. Packages installing info files</a></span></dt>
363: <dt><span class="sect2"><a href="#manpages">19.6.8. Packages installing man pages</a></span></dt>
1.7 rillig 364: <dt><span class="sect2"><a href="#gconf-data-files">19.6.9. Packages installing GConf data files</a></span></dt>
1.6 rillig 365: <dt><span class="sect2"><a href="#scrollkeeper-data-files">19.6.10. Packages installing scrollkeeper data files</a></span></dt>
366: <dt><span class="sect2"><a href="#x11-fonts">19.6.11. Packages installing X11 fonts</a></span></dt>
367: <dt><span class="sect2"><a href="#gtk2-modules">19.6.12. Packages installing GTK2 modules</a></span></dt>
368: <dt><span class="sect2"><a href="#sgml-xml-data">19.6.13. Packages installing SGML or XML data</a></span></dt>
369: <dt><span class="sect2"><a href="#mime-database">19.6.14. Packages installing extensions to the MIME database</a></span></dt>
370: <dt><span class="sect2"><a href="#intltool">19.6.15. Packages using intltool</a></span></dt>
371: <dt><span class="sect2"><a href="#startup-scripts">19.6.16. Packages installing startup scripts</a></span></dt>
372: <dt><span class="sect2"><a href="#tex-packages">19.6.17. Packages installing TeX modules</a></span></dt>
373: <dt><span class="sect2"><a href="#emulation-packages">19.6.18. Packages supporting running binaries in
1.1 dsieger 374: emulation</a></span></dt>
1.6 rillig 375: <dt><span class="sect2"><a href="#hicolor-theme">19.6.19. Packages installing hicolor theme icons</a></span></dt>
376: <dt><span class="sect2"><a href="#desktop-files">19.6.20. Packages installing desktop files</a></span></dt>
1.1 dsieger 377: </dl></dd>
1.6 rillig 378: <dt><span class="sect1"><a href="#punting">19.7. Marking packages as having problems</a></span></dt>
1.1 dsieger 379: </dl></dd>
1.6 rillig 380: <dt><span class="chapter"><a href="#debug">20. Debugging</a></span></dt>
381: <dt><span class="chapter"><a href="#submit">21. Submitting and Committing</a></span></dt>
1.1 dsieger 382: <dd><dl>
1.6 rillig 383: <dt><span class="sect1"><a href="#submitting-binary-packages">21.1. Submitting binary packages</a></span></dt>
384: <dt><span class="sect1"><a href="#submitting-your-package">21.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
385: <dt><span class="sect1"><a href="#general-notes-for-changes">21.3. General notes when adding, updating, or removing packages</a></span></dt>
386: <dt><span class="sect1"><a href="#committing-importing">21.4. Committing: Importing a package into CVS</a></span></dt>
387: <dt><span class="sect1"><a href="#updating-package">21.5. Updating a package to a newer version</a></span></dt>
388: <dt><span class="sect1"><a href="#moving-package">21.6. Moving a package in pkgsrc</a></span></dt>
389: </dl></dd>
390: <dt><span class="chapter"><a href="#devfaq">22. Frequently Asked Questions</a></span></dt>
391: <dt><span class="chapter"><a href="#gnome">23. GNOME packaging and porting</a></span></dt>
392: <dd><dl>
393: <dt><span class="sect1"><a href="#meta-packages">23.1. Meta packages</a></span></dt>
394: <dt><span class="sect1"><a href="#new-package">23.2. Packaging a GNOME application</a></span></dt>
395: <dt><span class="sect1"><a href="#full-update">23.3. Updating GNOME to a newer version</a></span></dt>
396: <dt><span class="sect1"><a href="#patching">23.4. Patching guidelines</a></span></dt>
1.1 dsieger 397: </dl></dd>
398: </dl></dd>
399: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
400: <dd><dl>
1.6 rillig 401: <dt><span class="chapter"><a href="#infr.design">24. Design of the pkgsrc infrastructure</a></span></dt>
1.1 dsieger 402: <dd><dl>
1.6 rillig 403: <dt><span class="sect1"><a href="#infr.vardef">24.1. The meaning of variable definitions</a></span></dt>
404: <dt><span class="sect1"><a href="#infr.vardef.problems">24.2. Avoiding problems before they arise</a></span></dt>
405: <dt><span class="sect1"><a href="#infr.var">24.3. Variable evaluation</a></span></dt>
1.1 dsieger 406: <dd><dl>
1.6 rillig 407: <dt><span class="sect2"><a href="#infr.var.load">24.3.1. At load time</a></span></dt>
408: <dt><span class="sect2"><a href="#infr.var.run">24.3.2. At runtime</a></span></dt>
1.1 dsieger 409: </dl></dd>
1.6 rillig 410: <dt><span class="sect1"><a href="#infr.varspec">24.4. How can variables be specified?</a></span></dt>
411: <dt><span class="sect1"><a href="#infr.design.intf">24.5. Designing interfaces for Makefile fragments</a></span></dt>
1.1 dsieger 412: <dd><dl>
1.6 rillig 413: <dt><span class="sect2"><a href="#infr.design.intf.proc">24.5.1. Procedures with parameters</a></span></dt>
414: <dt><span class="sect2"><a href="#infr.design.intf.action">24.5.2. Actions taken on behalf of parameters</a></span></dt>
1.1 dsieger 415: </dl></dd>
1.6 rillig 416: <dt><span class="sect1"><a href="#infr.order">24.6. The order in which files are loaded</a></span></dt>
1.1 dsieger 417: <dd><dl>
1.6 rillig 418: <dt><span class="sect2"><a href="#infr.order.prefs">24.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
419: <dt><span class="sect2"><a href="#infr.order.pkg">24.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.1 dsieger 420: </dl></dd>
421: </dl></dd>
1.6 rillig 422: <dt><span class="chapter"><a href="#regression">25. Regression tests</a></span></dt>
1.1 dsieger 423: <dd><dl>
1.6 rillig 424: <dt><span class="sect1"><a href="#regression.descr">25.1. The regression tests framework</a></span></dt>
425: <dt><span class="sect1"><a href="#regression.run">25.2. Running the regression tests</a></span></dt>
426: <dt><span class="sect1"><a href="#regression.new">25.3. Adding a new regression test</a></span></dt>
1.1 dsieger 427: <dd><dl>
1.6 rillig 428: <dt><span class="sect2"><a href="#regression.fun.override">25.3.1. Overridable functions</a></span></dt>
429: <dt><span class="sect2"><a href="#regression.fun.helper">25.3.2. Helper functions</a></span></dt>
1.1 dsieger 430: </dl></dd>
431: </dl></dd>
1.6 rillig 432: <dt><span class="chapter"><a href="#porting">26. Porting pkgsrc</a></span></dt>
1.1 dsieger 433: <dd><dl>
1.6 rillig 434: <dt><span class="sect1"><a href="#porting.opsys">26.1. Porting pkgsrc to a new operating system</a></span></dt>
435: <dt><span class="sect1"><a href="#porting.compiler">26.2. Adding support for a new compiler</a></span></dt>
1.1 dsieger 436: </dl></dd>
437: </dl></dd>
438: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
439: <dd><dl>
440: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
441: <dd><dl>
442: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
443: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
444: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
1.10 hubertf 445: <dt><span class="sect2"><a href="#checking-package-with-pkglint">A.1.4. Checking a package with <span class="command"><strong>pkglint</strong></span></a></span></dt>
1.1 dsieger 446: </dl></dd>
447: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
448: </dl></dd>
449: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
450: <dd><dl>
451: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
452: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
453: </dl></dd>
454: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
455: <dd><dl>
456: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
457: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
458: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
459: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
1.3 rillig 460: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages</code>: Binary packages</a></span></dt>
1.8 rillig 461: <dt><span class="sect1"><a href="#ftp-reports">C.6. <code class="filename">reports</code>: Bulk build reports</a></span></dt>
462: <dt><span class="sect1"><a href="#ftp-source">C.7. <code class="filename">current</code>,
1.1 dsieger 463: <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
464: source packages</a></span></dt>
465: </dl></dd>
466: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
467: <dd><dl>
468: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
469: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
470: </dl></dd>
471: </dl>
472: </div>
473: <div class="list-of-tables">
474: <p><b>List of Tables</b></p>
475: <dl>
476: <dt>1.1. <a href="#supported-platforms">Platforms supported by pkgsrc</a>
477: </dt>
1.6 rillig 478: <dt>11.1. <a href="#patch-examples">Patching examples</a>
1.1 dsieger 479: </dt>
1.6 rillig 480: <dt>23.1. <a href="#plist-handling">PLIST handling for GNOME packages</a>
1.1 dsieger 481: </dt>
482: </dl>
483: </div>
484: <div class="chapter" lang="en">
485: <div class="titlepage"><div><div><h2 class="title">
486: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
487: <div class="toc">
488: <p><b>Table of Contents</b></p>
489: <dl>
490: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
491: <dd><dl>
492: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
493: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
494: </dl></dd>
495: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
496: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
497: <dd><dl><dt><span class="sect2"><a href="#term.roles">1.3.1. Roles involved in pkgsrc</a></span></dt></dl></dd>
498: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
499: </dl>
500: </div>
501: <div class="sect1" lang="en">
502: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
503: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
504: <p>There is a lot of software freely available for Unix-based
505: systems, which is usually available in form of the source code. Before
506: such software can be used, it needs to be configured to the local
507: system, compiled and installed, and this is exactly what The NetBSD
508: Packages Collection (pkgsrc) does. pkgsrc also has some basic commands
509: to handle binary packages, so that not every user has to build the
510: packages for himself, which is a time-costly task.</p>
511: <p>pkgsrc currently contains several thousand packages,
512: including:</p>
513: <div class="itemizedlist"><ul type="disc">
514: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/apache/README.html" target="_top"><code class="filename">www/apache</code></a> - The Apache
515: web server</p></li>
516: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a> - The Firefox
517: web browser</p></li>
518: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome/README.html" target="_top"><code class="filename">meta-pkgs/gnome</code></a> - The GNOME
519: Desktop Environment</p></li>
520: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/kde3/README.html" target="_top"><code class="filename">meta-pkgs/kde3</code></a> - The K
521: Desktop Environment</p></li>
522: </ul></div>
523: <p>...just to name a few.</p>
524: <p>pkgsrc has built-in support for handling varying dependencies,
525: such as pthreads and X11, and extended features such as IPv6 support on
526: a range of platforms.</p>
527: <div class="sect2" lang="en">
528: <div class="titlepage"><div><div><h3 class="title">
529: <a name="why-pkgsrc"></a>1.1.1. Why pkgsrc?</h3></div></div></div>
530: <p>
531: pkgsrc provides the following key features:
532: </p>
533: <div class="itemizedlist"><ul type="disc">
534: <li><p>Easy building of software from source as well as the creation
535: and installation of binary packages. The source and latest
536: patches are retrieved from a master or mirror download site, checksum
537: verified, then built on your system. Support for binary-only
538: distributions is available for both native platforms and NetBSD
539: emulated platforms.</p></li>
540: <li><p>All packages are installed in a consistent directory tree,
541: including binaries, libraries, man pages and other
542: documentation.</p></li>
543: <li><p>Package dependencies, including when performing package updates,
544: are handled automatically. The configuration files of various
545: packages are handled automatically during updates, so local changes
546: are preserved.</p></li>
547: <li><p>Like NetBSD, pkgsrc is designed with portability in mind and
548: consists of highly portable code. This allows the greatest speed of
549: development when porting to new a platform. This portability also
550: ensures that pkgsrc is <span class="emphasis"><em>consistent across all
551: platforms</em></span>.</p></li>
552: <li><p>The installation prefix, acceptable software licenses,
553: international encryption requirements and build-time options for a
554: large number of packages are all set in a simple, central
555: configuration file.</p></li>
556: <li><p>The entire source (not including the distribution files) is
557: freely available under a BSD license, so you may extend and adapt
558: pkgsrc to your needs. Support for local packages and patches is
559: available right out of the box, so you can configure it specifically
560: for your environment.</p></li>
561: </ul></div>
562: <p>The following principles are basic to pkgsrc:</p>
563: <div class="itemizedlist"><ul type="disc">
564: <li><p>“<span class="quote">It should only work if it's right.</span>”
1.14 ! jmcneill 565: — That means, if a package contains bugs, it's better to find
1.1 dsieger 566: them and to complain about them rather than to just install the package
567: and hope that it works. There are numerous checks in pkgsrc that try to
568: find such bugs: Static analysis tools (<a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>), build-time checks (portability
569: of shell scripts), and post-installation checks (installed files,
570: references to shared libraries, script interpreters).</p></li>
571: <li><p>“<span class="quote">If it works, it should work everywhere</span>”
1.14 ! jmcneill 572: — Like NetBSD has been ported to many hardware architectures,
1.1 dsieger 573: pkgsrc has been ported to many operating systems. Care is taken that
574: packages behave the same on all platforms.</p></li>
575: </ul></div>
576: </div>
577: <div class="sect2" lang="en">
578: <div class="titlepage"><div><div><h3 class="title">
579: <a name="intro.platforms"></a>1.1.2. Supported platforms</h3></div></div></div>
580: <p>pkgsrc consists of both a source distribution and a binary
581: distribution for these operating systems. After retrieving the required
582: source or binaries, you can be up and running with pkgsrc in just
583: minutes!</p>
584: <p>pkgsrc was derived from FreeBSD's ports system, and
585: initially developed for NetBSD only. Since then, pkgsrc has
586: grown a lot, and now supports the following platforms:</p>
587: <div class="table">
588: <a name="supported-platforms"></a><p class="title"><b>Table 1.1. Platforms supported by pkgsrc</b></p>
589: <div class="table-contents"><table summary="Platforms supported by pkgsrc" border="1">
590: <colgroup>
591: <col>
592: <col>
593: </colgroup>
594: <thead><tr>
595: <th>Platform</th>
596: <th>Date Support Added</th>
597: </tr></thead>
598: <tbody>
599: <tr>
1.10 hubertf 600: <td><a class="ulink" href="http://www.NetBSD.org/" target="_top">NetBSD</a></td>
1.1 dsieger 601: <td align="center">Aug 1997</td>
602: </tr>
603: <tr>
1.10 hubertf 604: <td><a class="ulink" href="http://wwws.sun.com/software/solaris/" target="_top">Solaris</a></td>
1.1 dsieger 605: <td align="center">Mar 1999</td>
606: </tr>
607: <tr>
1.10 hubertf 608: <td><a class="ulink" href="http://www.kernel.org/" target="_top">Linux</a></td>
1.1 dsieger 609: <td align="center">Jun 1999</td>
610: </tr>
611: <tr>
612: <td>
1.10 hubertf 613: <a class="ulink" href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
614: (<a class="ulink" href="http://developer.apple.com/macosx/" target="_top">Mac OS X</a>)
1.1 dsieger 615: </td>
616: <td align="center">Oct 2001</td>
617: </tr>
618: <tr>
1.10 hubertf 619: <td><a class="ulink" href="http://www.freebsd.org/" target="_top">FreeBSD</a></td>
1.1 dsieger 620: <td align="center">Nov 2002</td>
621: </tr>
622: <tr>
1.10 hubertf 623: <td><a class="ulink" href="http://www.openbsd.org/" target="_top">OpenBSD</a></td>
1.1 dsieger 624: <td align="center">Nov 2002</td>
625: </tr>
626: <tr>
1.10 hubertf 627: <td><a class="ulink" href="http://www.sgi.com/software/irix/" target="_top">IRIX</a></td>
1.1 dsieger 628: <td align="center">Dec 2002</td>
629: </tr>
630: <tr>
631: <td>BSD/OS</td>
632: <td align="center">Dec 2003</td>
633: </tr>
634: <tr>
1.10 hubertf 635: <td><a class="ulink" href="http://www-1.ibm.com/servers/aix/" target="_top">AIX</a></td>
1.1 dsieger 636: <td align="center">Dec 2003</td>
637: </tr>
638: <tr>
639: <td>
1.10 hubertf 640: <a class="ulink" href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a>
1.1 dsieger 641: (Microsoft Windows Services for Unix)
642: </td>
643: <td align="center">Mar 2004</td>
644: </tr>
645: <tr>
1.10 hubertf 646: <td><a class="ulink" href="http://www.dragonflybsd.org/" target="_top">DragonFlyBSD</a></td>
1.1 dsieger 647: <td align="center">Oct 2004</td>
648: </tr>
649: <tr>
1.10 hubertf 650: <td><a class="ulink" href="http://www.tru64.org/" target="_top">OSF/1</a></td>
1.1 dsieger 651: <td align="center">Nov 2004</td>
652: </tr>
653: <tr>
1.10 hubertf 654: <td><a class="ulink" href="http://www.hp.com/products1/unix/" target="_top">HP-UX</a></td>
1.1 dsieger 655: <td align="center">Apr 2007</td>
656: </tr>
657: </tbody>
658: </table></div>
659: </div>
660: <br class="table-break">
661: </div>
662: </div>
663: <div class="sect1" lang="en">
664: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
665: <a name="overview"></a>1.2. Overview</h2></div></div></div>
666: <p>This document is divided into three parts. The first,
1.10 hubertf 667: <a class="link" href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
1.1 dsieger 668: describes how one can use one of the packages in the Package
669: Collection, either by installing a precompiled binary package,
670: or by building one's own copy using the NetBSD package system.
1.10 hubertf 671: The second part, <a class="link" href="#developers-guide" title="Part II. The pkgsrc developer's guide">The pkgsrc developer's guide</a>, explains how to prepare a
1.1 dsieger 672: package so it can be easily built by other NetBSD users without
673: knowing about the package's building details. The third part,
1.10 hubertf 674: <a class="link" href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
1.1 dsieger 675: is intended for those who want to understand how pkgsrc is
676: implemented.</p>
677: <p>This document is available in various formats:
1.10 hubertf 678: <span class="simplelist"><a class="ulink" href="index.html" target="_top">HTML</a>, <a class="ulink" href="pkgsrc.pdf" target="_top">PDF</a>, <a class="ulink" href="pkgsrc.ps" target="_top">PS</a>, <a class="ulink" href="pkgsrc.txt" target="_top">TXT</a></span>.</p>
1.1 dsieger 679: </div>
680: <div class="sect1" lang="en">
681: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
682: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
683: <p>There has been a lot of talk about “<span class="quote">ports</span>”,
684: “<span class="quote">packages</span>”, etc. so far. Here is a description of all the
685: terminology used within this document.</p>
686: <div class="variablelist"><dl>
687: <dt><span class="term">Package</span></dt>
688: <dd><p>A set of files and building instructions
689: that describe what's necessary
690: to build a certain piece of software using
691: pkgsrc. Packages are traditionally stored under
692: <code class="filename">/usr/pkgsrc</code>.</p></dd>
693: <dt><span class="term">The NetBSD package system</span></dt>
694: <dd><p>This is the former name of “<span class="quote">pkgsrc</span>”. It
695: is part of the NetBSD operating system and can be bootstrapped
696: to run on non-NetBSD operating systems as well. It handles
697: building (compiling), installing, and removing of
698: packages.</p></dd>
699: <dt><span class="term">Distfile</span></dt>
700: <dd><p>This term describes the file or files that are
701: provided by the author of the piece of software to
702: distribute his work. All the changes necessary to build on
703: NetBSD are reflected in the corresponding package. Usually
704: the distfile is in the form of a compressed tar-archive,
705: but other types are possible, too. Distfiles are usually
706: stored below
707: <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
708: <dt><span class="term">Port</span></dt>
709: <dd><p>This is the term used by FreeBSD and OpenBSD people
710: for what we call a package.
711: In NetBSD terminology, “<span class="quote">port</span>” refers to a different
712: architecture.</p></dd>
713: <dt><span class="term">Precompiled/binary package</span></dt>
714: <dd>
715: <p>A set of binaries built with pkgsrc from a distfile
716: and stuffed together in a single <code class="filename">.tgz</code>
717: file so it can be installed on machines of the same
718: machine architecture without the need to
719: recompile. Packages are usually generated in
720: <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.10 hubertf 721: an archive on <a class="ulink" href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
1.1 dsieger 722: <p>Sometimes, this is referred to by the term “<span class="quote">package</span>” too,
723: especially in the context of precompiled packages.</p>
724: </dd>
725: <dt><span class="term">Program</span></dt>
726: <dd><p>The piece of software to be installed which will be
727: constructed from all the files in the distfile by the
728: actions defined in the corresponding package.</p></dd>
729: </dl></div>
730: <div class="sect2" lang="en">
731: <div class="titlepage"><div><div><h3 class="title">
732: <a name="term.roles"></a>1.3.1. Roles involved in pkgsrc</h3></div></div></div>
733: <div class="variablelist"><dl>
734: <dt><span class="term">pkgsrc users</span></dt>
735: <dd>
736: <p>The
737: pkgsrc users are people who use the packages provided by pkgsrc.
738: Typically they are system administrators. The people using the
739: software that is inside the packages (maybe called “<span class="quote">end
740: users</span>”) are not covered by the pkgsrc guide.</p>
741: <p>There are two kinds of pkgsrc users: Some only want to
742: install pre-built binary packages. Others build the pkgsrc
743: packages from source, either for installing them directly or for
1.10 hubertf 744: building binary packages themselves. For pkgsrc users <a class="xref" href="#users-guide" title="Part I. The pkgsrc user's guide">Part I, “The pkgsrc user's guide”</a> should provide all necessary
1.1 dsieger 745: documentation.</p>
746: </dd>
747: <dt><span class="term">package maintainers</span></dt>
748: <dd><p>A
1.10 hubertf 749: package maintainer creates packages as described in <a class="xref" href="#developers-guide" title="Part II. The pkgsrc developer's guide">Part II, “The pkgsrc developer's guide”</a>.</p></dd>
1.1 dsieger 750: <dt><span class="term">infrastructure developers</span></dt>
751: <dd><p>These people are involved in all those files
752: that live in the <code class="filename">mk/</code> directory and below.
1.10 hubertf 753: Only these people should need to read through <a class="xref" href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">Part III, “The pkgsrc infrastructure internals”</a>, though others might be curious,
1.1 dsieger 754: too.</p></dd>
755: </dl></div>
756: </div>
757: </div>
758: <div class="sect1" lang="en">
759: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
760: <a name="typography"></a>1.4. Typography</h2></div></div></div>
761: <p>When giving examples for commands, shell prompts are used to
762: show if the command should/can be issued as root, or if
763: “<span class="quote">normal</span>” user privileges are sufficient. We use a
764: <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
765: shell prompt, assuming they use the C-shell or tcsh.</p>
766: </div>
767: </div>
768: <div class="part" lang="en">
769: <div class="titlepage"><div><div><h1 class="title">
770: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
771: <div class="toc">
772: <p><b>Table of Contents</b></p>
773: <dl>
774: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
775: <dd><dl>
776: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
777: <dd><dl>
778: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
779: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
780: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via anonymous CVS</a></span></dt>
781: </dl></dd>
782: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
783: <dd><dl>
784: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
785: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
786: </dl></dd>
787: </dl></dd>
788: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
789: <dd><dl>
790: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
791: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
792: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
793: <dd><dl>
794: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
795: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
796: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
797: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
798: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
799: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
800: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
801: </dl></dd>
802: </dl></dd>
803: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
804: <dd><dl>
805: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
806: <dd><dl>
807: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
808: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
809: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
810: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
811: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
812: <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>
813: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
814: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
815: </dl></dd>
816: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
817: <dd><dl>
818: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
819: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
820: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
821: </dl></dd>
822: </dl></dd>
823: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
824: <dd><dl>
825: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
826: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.9 rillig 827: <dt><span class="sect1"><a href="#variables-affecting-installation">5.3. Variables affecting the installation process</a></span></dt>
1.4 rillig 828: <dt><span class="sect1"><a href="#conf.compiler">5.4. Selecting and configuring the compiler</a></span></dt>
1.1 dsieger 829: <dd><dl>
1.4 rillig 830: <dt><span class="sect2"><a href="#selecting-the-compiler">5.4.1. Selecting the compiler</a></span></dt>
831: <dt><span class="sect2"><a href="#conf.cflags">5.4.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
832: <dt><span class="sect2"><a href="#conf.ldflags">5.4.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
1.1 dsieger 833: </dl></dd>
1.4 rillig 834: <dt><span class="sect1"><a href="#developer-advanced-settings">5.5. Developer/advanced settings</a></span></dt>
835: <dt><span class="sect1"><a href="#selecting-build-options">5.6. Selecting Build Options</a></span></dt>
1.1 dsieger 836: </dl></dd>
837: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
838: <dd><dl>
839: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
840: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
1.6 rillig 841: </dl></dd>
842: <dt><span class="chapter"><a href="#bulk">7. Creating binary packages for everything in pkgsrc (bulk
843: builds)</a></span></dt>
1.1 dsieger 844: <dd><dl>
1.6 rillig 845: <dt><span class="sect1"><a href="#bulk.pre">7.1. Think first, build later</a></span></dt>
846: <dt><span class="sect1"><a href="#bulk.req">7.2. Requirements of a bulk build</a></span></dt>
847: <dt><span class="sect1"><a href="#bulk.old">7.3. Running an old-style bulk build</a></span></dt>
848: <dd><dl>
849: <dt><span class="sect2"><a href="#binary.configuration">7.3.1. Configuration</a></span></dt>
850: <dt><span class="sect2"><a href="#other-environmental-considerations">7.3.2. Other environmental considerations</a></span></dt>
851: <dt><span class="sect2"><a href="#operation">7.3.3. Operation</a></span></dt>
852: <dt><span class="sect2"><a href="#what-it-does">7.3.4. What it does</a></span></dt>
853: <dt><span class="sect2"><a href="#disk-space-requirements">7.3.5. Disk space requirements</a></span></dt>
854: <dt><span class="sect2"><a href="#setting-up-a-sandbox">7.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
855: <dt><span class="sect2"><a href="#building-a-partial-set">7.3.7. Building a partial set of packages</a></span></dt>
856: <dt><span class="sect2"><a href="#bulk-upload">7.3.8. Uploading results of a bulk build</a></span></dt>
857: </dl></dd>
858: <dt><span class="sect1"><a href="#bulk.pbulk">7.4. Running a pbulk-style bulk build</a></span></dt>
859: <dd><dl><dt><span class="sect2"><a href="#bulk.pbulk.conf">7.4.1. Configuration</a></span></dt></dl></dd>
860: <dt><span class="sect1"><a href="#creating-cdroms">7.5. Creating a multiple CD-ROM packages collection</a></span></dt>
861: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">7.5.1. Example of cdpack</a></span></dt></dl></dd>
862: </dl></dd>
863: <dt><span class="chapter"><a href="#files">8. Directory layout of the installed files</a></span></dt>
864: <dd><dl>
865: <dt><span class="sect1"><a href="#files.localbase">8.1. File system layout in <code class="literal">${LOCALBASE}</code></a></span></dt>
866: <dt><span class="sect1"><a href="#files.varbase">8.2. File system layout in <code class="literal">${VARBASE}</code></a></span></dt>
867: </dl></dd>
868: <dt><span class="chapter"><a href="#faq">9. Frequently Asked Questions</a></span></dt>
869: <dd><dl>
870: <dt><span class="sect1"><a href="#mailing-list-pointers">9.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
871: <dt><span class="sect1"><a href="#pkgviews-docs">9.2. Where's the pkgviews documentation?</a></span></dt>
872: <dt><span class="sect1"><a href="#faq-pkgtools">9.3. Utilities for package management (pkgtools)</a></span></dt>
873: <dt><span class="sect1"><a href="#non-root-pkgsrc">9.4. How to use pkgsrc as non-root</a></span></dt>
874: <dt><span class="sect1"><a href="#resume-transfers">9.5. How to resume transfers when fetching distfiles?</a></span></dt>
875: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">9.6. How can I install/use modular X.org from pkgsrc?</a></span></dt>
876: <dt><span class="sect1"><a href="#fetch-behind-firewall">9.7. How to fetch files from behind a firewall</a></span></dt>
1.10 hubertf 877: <dt><span class="sect1"><a href="#passive-ftp">9.8. How do I tell <span class="command"><strong>make fetch</strong></span> to do passive FTP?</a></span></dt>
1.6 rillig 878: <dt><span class="sect1"><a href="#fetching-all-distfiles">9.9. How to fetch all distfiles at once</a></span></dt>
879: <dt><span class="sect1"><a href="#tmac.andoc-missing">9.10. What does “<span class="quote">Don't know how to make
1.1 dsieger 880: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
1.6 rillig 881: <dt><span class="sect1"><a href="#bsd.own.mk-missing">9.11. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</a></span></dt>
882: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">9.12. Using 'sudo' with pkgsrc</a></span></dt>
883: <dt><span class="sect1"><a href="#faq.conf">9.13. How do I change the location of configuration files?</a></span></dt>
884: <dt><span class="sect1"><a href="#audit-packages">9.14. Automated security checks</a></span></dt>
885: <dt><span class="sect1"><a href="#ufaq-cflags">9.15. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
886: <dt><span class="sect1"><a href="#ufaq-fail">9.16. A package does not build. What shall I do?</a></span></dt>
887: <dt><span class="sect1"><a href="#faq.rcs-conflicts">9.17. What does “<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>” mean?</a></span></dt>
1.1 dsieger 888: </dl></dd>
889: </dl>
890: </div>
891: <div class="chapter" lang="en">
892: <div class="titlepage"><div><div><h2 class="title">
893: <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
894: <div class="toc">
895: <p><b>Table of Contents</b></p>
896: <dl>
897: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
898: <dd><dl>
899: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
900: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
901: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via anonymous CVS</a></span></dt>
902: </dl></dd>
903: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
904: <dd><dl>
905: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
906: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
907: </dl></dd>
908: </dl>
909: </div>
910: <p>Before you download and extract the files, you need to decide
911: where you want to extract them. When using pkgsrc as root user, pkgsrc
912: is usually installed in <code class="filename">/usr/pkgsrc</code>. You are though
913: free to install the sources and binary packages wherever you want in
914: your filesystem, provided that the pathname does not contain white-space
915: or other characters that are interpreted specially by the shell and some
916: other programs. A safe bet is to use only letters, digits, underscores
917: and dashes.</p>
918: <div class="sect1" lang="en">
919: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
920: <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
921: <p>Before you download any pkgsrc files, you should decide
922: whether you want the <span class="emphasis"><em>current</em></span> branch or the
923: <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
924: quarterly basis from the current branch and only gets modified
925: for security updates. The names of the stable branches are built
926: from the year and the quarter, for example
1.12 weinem 927: <code class="literal">2007Q4</code>.</p>
1.1 dsieger 928: <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
929: want to download pkgsrc. You can get it as a tar file, via SUP,
930: or via CVS. All three ways are described here.</p>
931: <div class="sect2" lang="en">
932: <div class="titlepage"><div><div><h3 class="title">
933: <a name="getting-via-tar"></a>2.1.1. As tar file</h3></div></div></div>
934: <p>The primary download location for all pkgsrc files is
1.10 hubertf 935: <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>. There are a
1.1 dsieger 936: number of subdirectories for different purposes, which are
1.10 hubertf 937: described in detail in <a class="xref" 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.1 dsieger 938: <p>The tar file for the current branch is in the directory
1.10 hubertf 939: <code class="filename">current</code> and is called <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz" target="_top"><code class="filename">pkgsrc.tar.gz</code></a>.
1.1 dsieger 940: It is autogenerated daily.</p>
1.12 weinem 941: <p>The tar file for the stable branch 2007Q4 is in the
942: directory <code class="filename">pkgsrc-2007Q4</code> and is also called <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2007Q4/pkgsrc-2007Q4.tar.gz" target="_top"><code class="filename">pkgsrc-2007Q4.tar.gz</code></a>.</p>
943: <p>To download a pkgsrc stable tarball, run:</p>
944: <pre class="screen">
945: <code class="prompt">$</code> <strong class="userinput"><code>ftp ftp://ftp.NetBSD.org/pub/pkgsrc/<em class="replaceable"><code>pkgsrc-200xQy</code></em>/<em class="replaceable"><code>pkgsrc-200xQy</code></em>.tar.gz</code></strong></pre>
946: <p>Where <em class="replaceable"><code>pkgsrc-200xQy</code></em> is the
947: stable branch to be downloaded, for example,
948: “<span class="quote">pkgsrc-2007Q4</span>”.</p>
949: <p>Then, extract it with:</p>
950: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>tar -xzf <em class="replaceable"><code>pkgsrc-200xQy</code></em>.tar.gz -C /usr</code></strong></pre>
951: <p>This will create the directory <code class="filename">pkgsrc/</code>
952: in <code class="filename">/usr/</code> and all the package source will be
953: stored under <code class="filename">/usr/pkgsrc/</code>.</p>
954: <p>To download pkgsrc-current, run:</p>
955: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz</code></strong></pre>
1.1 dsieger 956: </div>
957: <div class="sect2" lang="en">
958: <div class="titlepage"><div><div><h3 class="title">
959: <a name="getting-via-sup"></a>2.1.2. Via SUP</h3></div></div></div>
960: <p>As an alternative to the tar file, you can get pkgsrc via
961: the Software Update Protocol, SUP. To do so, make sure your
962: supfile has a line
963:
964: </p>
965: <pre class="programlisting">
966: release=pkgsrc
967: </pre>
968: <p>
969:
970: in it, see the examples in
971: <code class="filename">/usr/share/examples/supfiles</code>, and that the
972: <code class="filename">/usr/pkgsrc</code> directory exists. Then, simply
1.13 weinem 973: run:</p>
974: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>sup -v <em class="replaceable"><code>/path/to/your/supfile</code></em></code></strong>.</pre>
1.1 dsieger 975: </div>
976: <div class="sect2" lang="en">
977: <div class="titlepage"><div><div><h3 class="title">
978: <a name="getting-via-cvs"></a>2.1.3. Via anonymous CVS</h3></div></div></div>
1.12 weinem 979: <p>To do an initial (full) checkout of pkgsrc, you first
1.1 dsieger 980: have to set some environment variables. For the C-Shell,
981: type:</p>
1.13 weinem 982: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
983: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVS_RSH ssh</code></strong>
1.1 dsieger 984: </pre>
985: <p>Or, the same for the bourne shell:</p>
1.13 weinem 986: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>export CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"</code></strong>
987: <code class="prompt">$</code> <strong class="userinput"><code>export CVS_RSH="ssh"</code></strong>
1.1 dsieger 988: </pre>
1.13 weinem 989: <p>By default, CVS doesn't do things like most people would
1.12 weinem 990: expect it to do. But there is a
1.13 weinem 991: way to convince CVS, by creating a file called
1.2 rillig 992: <code class="filename">.cvsrc</code> in your home directory and saving
993: the following lines to it. This file will save you lots of
994: headache and some bug reports, so we strongly recommend it. You
995: can find an explanation of this file in the CVS
996: documentation.</p>
997: <pre class="programlisting">
998: # recommended CVS configuration file from the pkgsrc guide
999: checkout -P
1.4 rillig 1000: update -dP
1.2 rillig 1001: release -d
1.4 rillig 1002: diff -upN
1.2 rillig 1003: cvs -q -z3
1004: rdiff -u
1005: </pre>
1.12 weinem 1006: <p>To fetch a specific pkgsrc stable branch from scratch, run:</p>
1007: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>cd /usr</code></strong>
1.13 weinem 1008: <code class="prompt">$</code> <strong class="userinput"><code>cvs checkout -r <em class="replaceable"><code>pkgsrc-200xQy</code></em> -P pkgsrc</code></strong></pre>
1.12 weinem 1009: <p>Where <em class="replaceable"><code>pkgsrc-200xQy</code></em> is the stable
1010: branch to be checked out, for example, “<span class="quote">pkgsrc-2007Q4</span>”</p>
1011: <p>This will create the directory <code class="filename">pkgsrc/</code>
1012: in your <code class="filename">/usr/</code> directory and all the package source
1013: will be stored under <code class="filename">/usr/pkgsrc/</code>.</p>
1014: <p>To fetch the pkgsrc current branch, run:</p>
1015: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>cd /usr</code></strong>
1.13 weinem 1016: <code class="prompt">$</code> <strong class="userinput"><code>cvs checkout -P pkgsrc</code></strong></pre>
1.1 dsieger 1017: </div>
1018: </div>
1019: <div class="sect1" lang="en">
1020: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1021: <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
1022: <p>The preferred way to keep pkgsrc up-to-date is via CVS
1023: (which also works if you have first installed it via a tar
1024: file). It saves bandwidth and hard disk activity, compared to
1025: downloading the tar file again.</p>
1026: <div class="sect2" lang="en">
1027: <div class="titlepage"><div><div><h3 class="title">
1028: <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
1029: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
1030: <h3 class="title">Warning</h3>
1031: <p>When updating from a tar file, you first need to
1032: completely remove the old pkgsrc directory. Otherwise those
1033: files that have been removed from pkgsrc in the mean time will
1034: not be removed on your local disk, resulting in inconsistencies.
1035: When removing the old files, any changes that you have done to
1036: the pkgsrc files will be lost after updating. Therefore updating
1037: via CVS is strongly recommended.</p>
1038: </div>
1039: <p>Note that by default the distfiles and the binary packages
1040: are saved in the pkgsrc tree, so don't forget to rescue them
1041: before updating. You can also configure pkgsrc to use other than
1042: the default directories by setting the
1043: <code class="varname">DISTDIR</code> and <code class="varname">PACKAGES</code>
1.10 hubertf 1044: variables. See <a class="xref" href="#configuring" title="Chapter 5. Configuring pkgsrc">Chapter 5, <i>Configuring pkgsrc</i></a> for the details.</p>
1.1 dsieger 1045: <p>To update pkgsrc from a tar file, download the tar file as
1046: explained above. Then, make sure that you have not made any
1047: changes to the files in the pkgsrc directory. Remove the pkgsrc
1048: directory and extract the new tar file. Done.</p>
1049: </div>
1050: <div class="sect2" lang="en">
1051: <div class="titlepage"><div><div><h3 class="title">
1052: <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
1053: <p>To update pkgsrc via CVS, make sure the environment
1054: variable <code class="varname">CVS_RSH</code> is set as above. Then,
1.13 weinem 1055: change to the <code class="filename">pkgsrc</code> directory and run cvs:</p>
1056: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
1057: <code class="prompt">$</code> <strong class="userinput"><code>cvs update -dP</code></strong></pre>
1.1 dsieger 1058: <div class="sect3" lang="en">
1059: <div class="titlepage"><div><div><h4 class="title">
1060: <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
1061: <p>When updating pkgsrc, the CVS program keeps track of the
1062: branch you selected. But if you, for whatever reason, want to
1063: switch from the stable branch to the current one, you can do it
1064: by adding the option “<span class="quote">-A</span>” after the
1065: “<span class="quote">update</span>” keyword. To switch from the current branch
1066: back to the stable branch, add the
1.13 weinem 1067: “<span class="quote">-rpkgsrc-2007Q4</span>” option.</p>
1.1 dsieger 1068: </div>
1069: <div class="sect3" lang="en">
1070: <div class="titlepage"><div><div><h4 class="title">
1071: <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
1072: <p>When you update pkgsrc, the CVS program will only touch
1073: those files that are registered in the CVS repository. That
1074: means that any packages that you created on your own will stay
1075: unmodified. If you change files that are managed by CVS, later
1076: updates will try to merge your changes with those that have been
1077: done by others. See the CVS manual, chapter
1078: “<span class="quote">update</span>” for details.</p>
1079: </div>
1080: </div>
1081: </div>
1082: </div>
1083: <div class="chapter" lang="en">
1084: <div class="titlepage"><div><div><h2 class="title">
1085: <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
1086: <div class="toc">
1087: <p><b>Table of Contents</b></p>
1088: <dl>
1089: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
1090: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
1091: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
1092: <dd><dl>
1093: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
1094: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
1095: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
1096: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
1097: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
1098: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
1099: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1100: </dl></dd>
1101: </dl>
1102: </div>
1103: <div class="sect1" lang="en">
1104: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1105: <a name="binarydist"></a>3.1. Binary distribution</h2></div></div></div>
1.10 hubertf 1106: <p>See <a class="xref" href="#using-pkg" title="4.1. Using binary packages">Section 4.1, “Using binary packages”</a>.</p>
1.1 dsieger 1107: </div>
1108: <div class="sect1" lang="en">
1109: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1110: <a name="bootstrapping-pkgsrc"></a>3.2. Bootstrapping pkgsrc</h2></div></div></div>
1111: <p>Installing the bootstrap kit from source should be as simple as:</p>
1112: <pre class="screen">
1113: <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
1114: <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1115: <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong>
1116: </pre>
1.10 hubertf 1117: <p>See <a class="xref" 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.1 dsieger 1118: pkgsrc before bootstrapping. The given
1.10 hubertf 1119: <span class="command"><strong>bootstrap</strong></span> command will use the defaults of
1.1 dsieger 1120: <code class="filename">/usr/pkg</code> for the
1121: <span class="emphasis"><em>prefix</em></span> where programs will be installed in,
1122: and <code class="filename">/var/db/pkg</code> for the package database
1123: directory where pkgsrc will do its internal bookkeeping.
1124: However, these can also be set using command-line
1125: arguments.</p>
1126: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1127: <h3 class="title">Note</h3>
1.10 hubertf 1128: <p>The bootstrap installs a <span class="command"><strong>bmake</strong></span> tool.
1129: Use this <span class="command"><strong>bmake</strong></span> when building via pkgsrc.
1130: For examples in this guide, use <span class="command"><strong>bmake</strong></span>
1.1 dsieger 1131: instead of “<span class="quote">make</span>”.</p>
1132: </div>
1133: </div>
1134: <div class="sect1" lang="en">
1135: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1136: <a name="platform-specific-notes"></a>3.3. Platform-specific notes</h2></div></div></div>
1137: <p>Here are some platform-specific notes you should be aware of.</p>
1138: <div class="sect2" lang="en">
1139: <div class="titlepage"><div><div><h3 class="title">
1140: <a name="darwin"></a>3.3.1. Darwin (Mac OS X)</h3></div></div></div>
1141: <p>Darwin 5.x and up are supported. There are two methods of using
1.10 hubertf 1142: pkgsrc on Mac OS X, by using a <a class="link" href="#platform.osx-image" title="3.3.1.1. Using a disk image">disk
1143: image</a>, or a <a class="link" href="#platform.osx-part" title="3.3.1.2. Using a UFS or HFSX partition">UFS or HFSX
1.1 dsieger 1144: partition</a>.</p>
1145: <p>Before you start, you will need to download and install the Mac OS X Developer
1.10 hubertf 1146: Tools from Apple's Developer Connection. See <a class="ulink" href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
1.1 dsieger 1147: for details. Also, make sure you install X11 for Mac OS X and the X11 SDK
1.10 hubertf 1148: from <a class="ulink" href="http://www.apple.com/macosx/x11/download/" target="_top">http://www.apple.com/macosx/x11/download/</a>
1.1 dsieger 1149: if you intend to build packages that use the X11 Window System.</p>
1150: <p>If you already have a UFS or HFSX partition, or have a spare partition
1151: that you can format as UFS or HFSX, it is recommended to use that instead of
1152: the disk image. It'll be somewhat faster and will mount automatically
1153: at boot time, where you must manually mount a disk image.</p>
1154: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1155: <h3 class="title">Note</h3>
1156: <p>You cannot use an ordinary HFS+ file system for pkgsrc, because pkgsrc currently
1157: 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>
1158: </div>
1159: <div class="sect3" lang="en">
1160: <div class="titlepage"><div><div><h4 class="title">
1161: <a name="platform.osx-image"></a>3.3.1.1. Using a disk image</h4></div></div></div>
1162: <p>Create the disk image:</p>
1163: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1164: <code class="prompt">#</code> <strong class="userinput"><code>./darwindiskimage create ~/Documents/NetBSD 1024</code></strong> # megabytes - season to taste
1165: <code class="prompt">#</code> <strong class="userinput"><code>./darwindiskimage mount ~/Documents/NetBSD</code></strong>
1166: <code class="prompt">#</code> <strong class="userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong></pre>
1167: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1168: <h3 class="title">Note</h3>
1.9 rillig 1169: <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 journaling.</p>
1.1 dsieger 1170: </div>
1171: <p>Allow suid:</p>
1172: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sudo mount -u -o suid /Volumes/NetBSD</code></strong></pre>
1.5 weinem 1173: <p>Changing the build directory:</p>
1174: <p>After bootstrapping you need to change the default package build directory to somewhere outside the disk image so it doesn't get filled up in the process of building packages. Add something like that to <code class="filename">mk.conf</code>.</p>
1175: <pre class="programlisting">
1176: WRKOBJDIR?= /tmp/pkgsrc # build here instead of in pkgsrc
1177: </pre>
1.1 dsieger 1178: </div>
1179: <div class="sect3" lang="en">
1180: <div class="titlepage"><div><div><h4 class="title">
1181: <a name="platform.osx-part"></a>3.3.1.2. Using a UFS or HFSX partition</h4></div></div></div>
1182: <p>By default, <code class="filename">/usr</code> will be on your root file
1183: system, normally HFS+. It is possible to use the default
1184: <span class="emphasis"><em>prefix</em></span> of <code class="filename">/usr/pkg</code>
1185: by symlinking <code class="filename">/usr/pkg</code> to a directory on a UFS
1186: or HFSX file system. Obviously, another symlink is required if you want to
1187: place the package database directory outside the
1188: <span class="emphasis"><em>prefix</em></span>. e.g.</p>
1189: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb</code></strong></pre>
1190: <p>If you created your partitions at the time of installing Mac OS X
1191: and formatted the target partition as UFS or HFSX, it should automatically
1192: mount on <code class="filename">/Volumes/<volume name></code> when the
1193: machine boots. If you are (re)formatting a partition as UFS or HFSX, you need
1194: to ensure that the partition map correctly reflects
1195: “<span class="quote">Apple_UFS</span>” or “<span class="quote">Apple_HFSX</span>” and not “<span class="quote">Apple_HFS</span>”.</p>
1196: <p>The problem is that none of the disk tools will let you touch a
1197: disk that is booted from. You can unmount the partition, but even if
1198: you newfs it, the partition type will be incorrect and the
1199: automounter won't mount it. It can be mounted manually, but it won't
1200: appear in Finder.</p>
1201: <p>You'll need to boot off of the OS X Installation (User) CD. When
1202: the Installation program starts, go up to the menu and select Disk
1203: Utility. Now, you will be able to select the partition you want
1204: to be UFS or HFSX, and Format it Apple UFS or HFSX. Quit the Disk Utility, quit the
1205: installer which will reboot your machine. The new UFS or HFSX file system
1206: will appear in Finder.</p>
1207: <p>Be aware that the permissions on the new file system will be writable
1208: by root only.</p>
1209: <p>This note is as of 10.2 (Jaguar) and applies to earlier versions.
1210: Hopefully Apple will fix Disk Utility in 10.3 (Panther).</p>
1211: </div>
1212: </div>
1213: <div class="sect2" lang="en">
1214: <div class="titlepage"><div><div><h3 class="title">
1215: <a name="freebsd"></a>3.3.2. FreeBSD</h3></div></div></div>
1216: <p>FreeBSD 4.7 and 5.0 have been tested and are supported,
1217: other versions may work.</p>
1218: <p>Care should be taken so that the tools that this kit installs do not conflict
1219: with the FreeBSD userland tools. There are several steps:</p>
1220: <div class="orderedlist"><ol type="1">
1221: <li><p>FreeBSD stores its ports pkg database in
1222: <code class="filename">/var/db/pkg</code>. It is therefore
1223: recommended that you choose a different location (e.g.
1224: <code class="filename">/usr/pkgdb</code>) by
1225: using the --pkgdbdir option to the bootstrap script.</p></li>
1226: <li>
1227: <p>If you do not intend to use the FreeBSD ports tools, it's probably a
1228: good idea to move them out of the way to avoid confusion, e.g.</p>
1229: <pre class="screen">
1230: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1231: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1232: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1233: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1234: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong>
1235: </pre>
1236: </li>
1.10 hubertf 1237: <li><p>An example <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> file will be placed in
1.1 dsieger 1238: <code class="filename">/etc/mk.conf.example</code> file
1239: when you use the bootstrap script.</p></li>
1240: </ol></div>
1241: </div>
1242: <div class="sect2" lang="en">
1243: <div class="titlepage"><div><div><h3 class="title">
1244: <a name="interix"></a>3.3.3. Interix</h3></div></div></div>
1245: <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
1246: providing a Unix-like environment with a tighter kernel integration than
1247: available with Cygwin. It is part of the Windows Services for Unix
1248: package, available for free for any licensed copy of Windows 2000, XP
1.10 hubertf 1249: (not including XP Home), or 2003. SFU can be downloaded from <a class="ulink" href="http://www.microsoft.com/windows/sfu/" target="_top">http://www.microsoft.com/windows/sfu/</a>.</p>
1.1 dsieger 1250: <p>Services for Unix 3.5 has been tested. 3.0 or 3.1 may work, but
1251: are not officially supported. (The main difference in 3.0/3.1 is lack
1252: of pthreads, but other parts of libc may also be lacking.)</p>
1253: <p>Services for Unix Applications (aka SUA) is an integrated component
1254: of Windows Server 2003 R2 and Windows Vista. As of this writing, SUA's
1255: Interix 5.x subsystem has not yet been tested with pkgsrc.</p>
1256: <div class="sect3" lang="en">
1257: <div class="titlepage"><div><div><h4 class="title">
1258: <a name="platform.interix-sfu-install"></a>3.3.3.1. When installing Interix/SFU</h4></div></div></div>
1259: <p>At an absolute minimum, the following packages must be installed from
1260: the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
1261: <div class="itemizedlist"><ul type="disc">
1262: <li><p>Utilities -> Base Utilities</p></li>
1263: <li><p>Interix GNU Components -> (all)</p></li>
1264: <li><p>Remote Connectivity</p></li>
1265: <li><p>Interix SDK</p></li>
1266: </ul></div>
1267: <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
1268: "UNIX Perl". That is Perl 5.6 without shared module support, installed to
1269: /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
1270: pkgsrc (or from a binary package).</p>
1271: <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
1272: not need to be installed, but Remote Connectivity itself should be
1273: installed in order to have a working inetd.</p>
1274: <p>During installation you may be asked whether to enable setuid
1275: behavior for Interix programs, and whether to make pathnames default to
1276: case-sensitive. Setuid should be enabled, and case-sensitivity MUST be
1277: enabled. (Without case-sensitivity, a large number of packages including
1278: perl will not build.)</p>
1279: <p>NOTE: Newer Windows service packs change the way binary execution
1280: works (via the Data Execution Prevention feature). In order to use
1281: pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
1282: POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
1283: must be installed. Hotfixes are available from Microsoft through a
1.14 ! jmcneill 1284: support contract; however, Debian Interix Port has made most Interix
! 1285: hotfixes available for personal use from <a class="ulink" href="http://www.debian-interix.net/hotfixes/" target="_top">http://www.debian-interix.net/hotfixes/</a>.</p>
1.1 dsieger 1286: <p>In addition to the hotfix noted above, it may be necessary to
1287: disable Data Execution Prevention entirely to make Interix functional.
1288: This may happen only with certain types of CPUs; the cause is not fully
1289: understood at this time. If gcc or other applications still segfault
1290: repeatedly after installing one of the hotfixes note above, the
1291: following option can be added to the appropriate "boot.ini" line on the
1292: Windows boot drive: /NoExecute=AlwaysOff
1293: (WARNING, this will disable DEP completely, which may be a security
1294: risk if applications are often run as a user in the Administrators
1295: group!)</p>
1296: </div>
1297: <div class="sect3" lang="en">
1298: <div class="titlepage"><div><div><h4 class="title">
1299: <a name="platform.interix-sfu-postinstall"></a>3.3.3.2. What to do if Interix/SFU is already installed</h4></div></div></div>
1300: <p>If SFU is already installed and you wish to alter these settings to work
1301: with pkgsrc, note the following things.</p>
1302: <div class="itemizedlist"><ul type="disc">
1303: <li><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
1304: Windows Services for UNIX, then click Change. In the installer, choose
1305: Add or Remove, then uncheck Utilities->UNIX Perl.</p></li>
1306: <li>
1307: <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
1308: change the following registry key:</p>
1309: <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
1310: <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
1311: </li>
1312: <li>
1313: <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
1314: following registry key:</p>
1315: <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
1316: <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
1317: </li>
1318: </ul></div>
1319: </div>
1320: <div class="sect3" lang="en">
1321: <div class="titlepage"><div><div><h4 class="title">
1322: <a name="platform.interix-notes"></a>3.3.3.3. Important notes for using pkgsrc</h4></div></div></div>
1323: <p>The package manager (either the pkgsrc "su" user, or the user
1324: running "pkg_add") must be a member of the local Administrators
1325: group. Such a user must also be used to run the bootstrap. This is
1326: slightly relaxed from the normal pkgsrc requirement of "root".</p>
1327: <p>The package manager should use a umask of 002. "make install" will
1328: automatically complain if this is not the case. This ensures that
1329: directories written in /var/db/pkg are Administrators-group writeable.</p>
1330: <p>The popular Interix binary packages from http://www.interopsystems.com/
1331: use an older version of pkgsrc's pkg_* tools. Ideally, these should
1332: NOT be used in conjunction with pkgsrc. If you choose to use them at
1333: the same time as the pkgsrc packages, ensure that you use the proper
1334: pkg_* tools for each type of binary package.</p>
1335: <p>The TERM setting used for DOS-type console windows (including those
1336: invoked by the csh and ksh startup shortcuts) is "interix". Most systems
1337: don't have a termcap/terminfo entry for it, but the following .termcap
1338: entry provides adequate emulation in most cases:</p>
1339: <pre class="programlisting">
1340: interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
1341: </pre>
1342: </div>
1343: <div class="sect3" lang="en">
1344: <div class="titlepage"><div><div><h4 class="title">
1345: <a name="platform.interix-limits"></a>3.3.3.4. Limitations of the Interix platform</h4></div></div></div>
1346: <p>Though Interix suffices as a familiar and flexible substitute
1347: for a full Unix-like platform, it has some drawbacks that should
1348: be noted for those desiring to make the most of Interix.</p>
1349: <div class="itemizedlist"><ul type="disc">
1350: <li>
1351: <p><span class="strong"><strong>X11:</strong></span></p>
1352: <p>Interix comes with the standard set of X11R6 client libraries,
1353: and can run X11 based applications, but it does
1354: <span class="emphasis"><em>not</em></span> come with an X server. Some options are
1.10 hubertf 1355: <a class="ulink" href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
1356: <a class="ulink" href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
1.1 dsieger 1357: (available in a trimmed version for Interix from Interop Systems as the
1.10 hubertf 1358: <a class="ulink" href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
1.1 dsieger 1359: and the free X11 server included with
1.10 hubertf 1360: <a class="ulink" href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
1.1 dsieger 1361: </li>
1362: <li>
1363: <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
1364: <p>Because Interix runs in a completely different NT subsystem from
1365: Win32 applications, it does not currently support various X11
1366: protocol extensions for acceleration (such as MIT-SHM or DGA).
1367: Most interactive applications to a local X server will run
1368: reasonably fast, but full motion video and other graphics
1369: intensive applications may require a faster-than-expected CPU.</p>
1370: </li>
1371: <li>
1372: <p><span class="strong"><strong>Audio:</strong></span></p>
1373: <p>Interix has no native support for audio output. For audio
1.10 hubertf 1374: support, pkgsrc uses the <span class="command"><strong>esound</strong></span> client/server
1.1 dsieger 1375: audio system on Interix. Unlike on most platforms, the
1376: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/esound/README.html" target="_top"><code class="filename">audio/esound</code></a> package does
1.10 hubertf 1377: <span class="emphasis"><em>not</em></span> contain the <span class="command"><strong>esd</strong></span>
1.1 dsieger 1378: server component. To output audio via an Interix host, the
1379: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/emulators/cygwin_esound/README.html" target="_top"><code class="filename">emulators/cygwin_esound</code></a> package
1380: must also be installed.</p>
1381: </li>
1382: <li>
1383: <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
1384: <p>Direct device access is not currently supported in Interix, so it
1385: is not currently possible to access CD/DVD drives, USB devices,
1386: or SCSI devices through non-filesystem means. Among other things,
1387: this makes it impossible to use Interix directly for CD/DVD
1388: burning.</p>
1389: </li>
1390: <li>
1391: <p><span class="strong"><strong>Tape drives:</strong></span></p>
1392: <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
1393: drives are also not directly accessible in Interix. However,
1394: support is in work to make tape drive access possible by using
1395: Cygwin as a bridge (similarly to audio bridged via Cygwin's
1396: esound server).</p>
1397: </li>
1398: </ul></div>
1399: </div>
1400: <div class="sect3" lang="en">
1401: <div class="titlepage"><div><div><h4 class="title">
1402: <a name="platform.interix-knownissues"></a>3.3.3.5. Known issues for pkgsrc on Interix</h4></div></div></div>
1403: <p>It is not necessary, in general, to have a "root" user on the
1404: Windows system; any member of the local Administrators group will
1405: suffice. However, some packages currently assume that the user
1406: named "root" is the privileged user. To accommodate these, you
1407: may create such a user; make sure it is in the local group
1408: Administrators (or your language equivalent).</p>
1.10 hubertf 1409: <p><span class="command"><strong>pkg_add</strong></span> creates directories of mode
1.1 dsieger 1410: 0755, not 0775, in <code class="filename">$PKG_DBDIR</code>. For the
1411: time being, install packages as the local Administrator (or
1412: your language equivalent), or run the following command after
1413: installing a package to work around the issue:</p>
1414: <pre class="screen">
1415: <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong>
1416: </pre>
1417: </div>
1418: </div>
1419: <div class="sect2" lang="en">
1420: <div class="titlepage"><div><div><h3 class="title">
1421: <a name="irix"></a>3.3.4. IRIX</h3></div></div></div>
1422: <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
1423: compiler (cc/c89). Please set the <code class="varname">CC</code> environment variable
1424: according to your preference. If you do not have a license for the MIPSpro
1.10 hubertf 1425: compiler suite, you can download a gcc tardist file from <a class="ulink" href="http://freeware.sgi.com/" target="_top">http://freeware.sgi.com/</a>.</p>
1.1 dsieger 1426: <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
1.10 hubertf 1427: version of IRIX providing support for <a class="citerefentry" 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 class="citerefentry" 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>,
1.1 dsieger 1428: etc.</p>
1429: <p>At this point in time, pkgsrc only supports one ABI at a time. That is, you cannot
1430: switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI. If
1431: you start out using "abi=n32", that's what all your packages will be built
1432: with.</p>
1433: <p>Therefore, please make sure that you have no conflicting
1434: <code class="varname">CFLAGS</code> in your environment or the
1.10 hubertf 1435: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>. Particularly, make sure that you do not
1.1 dsieger 1436: try to link n32 object files with lib64 or vice versa. Check your
1437: <code class="filename">/etc/compiler.defaults</code>!</p>
1438: <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
1439: please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
1440: as it appears that IRIX linker occasionally runs into issues when trying to
1441: link over a network-mounted file system.</p>
1442: <p>The bootstrapping process should set all the right options for programs such
1443: as imake(1), but you may want to set some options depending on your local
1444: setup. Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
1445: course, your compiler's man pages for details.</p>
1446: <p>If you are using SGI's MIPSPro compiler, please set
1447:
1448: </p>
1449: <pre class="programlisting">
1450: PKGSRC_COMPILER= mipspro
1451: </pre>
1452: <p>
1453:
1.10 hubertf 1454: in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>. Otherwise, pkgsrc will assume you
1.1 dsieger 1455: are using gcc and may end up passing invalid flags to the compiler. Note that
1456: bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
1457: default.</p>
1458: <p>If you have both the MIPSPro compiler chain installed as well as gcc,
1459: but want to make sure that MIPSPro is used, please set your <code class="varname">PATH</code>
1460: to <span class="emphasis"><em>not</em></span> include the location of gcc (often
1461: <code class="filename">/usr/freeware/bin</code>), and (important) pass the
1462: '--preserve-path' flag.</p>
1463: </div>
1464: <div class="sect2" lang="en">
1465: <div class="titlepage"><div><div><h3 class="title">
1466: <a name="linux"></a>3.3.5. Linux</h3></div></div></div>
1467: <p>Some versions of Linux (for example Debian GNU/Linux) need
1468: either libtermcap or libcurses (libncurses). Installing the
1469: distributions libncurses-dev package (or equivalent) should fix
1470: the problem.</p>
1471: <p>pkgsrc supports both gcc (GNU Compiler Collection) and icc
1472: (Intel C++ Compiler). gcc is the default. icc 8.0 and 8.1 on
1473: i386 have been tested.</p>
1474: <p>To bootstrap using icc, assuming the default icc installation
1475: directory:</p>
1476: <pre class="programlisting">
1477: env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
1478: ac_cv___attribute__=yes ./bootstrap
1479: </pre>
1480: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1481: <h3 class="title">Note</h3>
1482: <p>icc 8.1 needs the `-i-static' argument instead of -static-libcxa.</p>
1483: </div>
1484: <p>icc supports __attribute__, but the GNU configure test uses a nested
1485: function, which icc does not support. #undef'ing __attribute__ has the
1486: unfortunate side-effect of breaking many of the Linux header files, which
1487: cannot be compiled properly without __attribute__. The test must be
1488: overridden so that __attribute__ is assumed supported by the
1489: compiler.</p>
1490: <p>After bootstrapping, you should set <code class="varname">PKGSRC_COMPILER</code>
1.10 hubertf 1491: in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>:</p>
1.1 dsieger 1492: <pre class="programlisting">
1493: PKGSRC_COMPILER= icc
1494: </pre>
1495: <p>The default installation directory for icc is
1496: <code class="filename">/opt/intel_cc_80</code>, which
1497: is also the pkgsrc default. If you have installed it into a different
1498: directory, set <code class="varname">ICCBASE</code> in
1.10 hubertf 1499: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>:</p>
1.1 dsieger 1500: <pre class="programlisting">
1501: ICCBASE= /opt/icc
1502: </pre>
1503: <p>pkgsrc uses the static linking method of the runtime libraries
1504: provided by icc, so binaries can be run on other systems which do not
1505: have the shared libraries installed.</p>
1506: <p>Libtool, however, extracts a list of libraries from the
1.10 hubertf 1507: <a class="citerefentry" 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
1.1 dsieger 1508: records it, throwing away the -Bstatic and -Bdynamic options
1509: interspersed between the libraries. This means that
1510: libtool-linked C++ shared libraries will have a runtime
1511: dependency on the icc libraries until this is fixed in
1512: libtool.</p>
1513: </div>
1514: <div class="sect2" lang="en">
1515: <div class="titlepage"><div><div><h3 class="title">
1516: <a name="openbsd"></a>3.3.6. OpenBSD</h3></div></div></div>
1517: <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
1518: <p>Care should be taken so that the tools that this kit installs do not conflict
1519: with the OpenBSD userland tools. There are several steps:</p>
1520: <div class="orderedlist"><ol type="1">
1521: <li><p>OpenBSD stores its ports pkg database in
1522: <code class="filename">/var/db/pkg</code>. It is therefore
1523: recommended that you choose a different location (e.g.
1524: <code class="filename">/usr/pkgdb</code>) by
1525: using the --pkgdbdir option to the bootstrap script.</p></li>
1526: <li>
1527: <p>If you do not intend to use the OpenBSD ports tools, it's probably a
1528: good idea to move them out of the way to avoid confusion, e.g.</p>
1529: <pre class="screen">
1530: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1531: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1532: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1533: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1534: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong>
1535: </pre>
1536: </li>
1537: <li>
1.10 hubertf 1538: <p>An example <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> file will be placed in
1.1 dsieger 1539: <code class="filename">/etc/mk.conf.example</code> file
1540: when you use the bootstrap script. OpenBSD's make program uses
1.10 hubertf 1541: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>
1.1 dsieger 1542: as well. You can work around this by enclosing all the pkgsrc-specific parts
1543: of the file with:</p>
1544: <pre class="programlisting">
1545: .ifdef BSD_PKG_MK
1546: # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
1547: .else
1548: # OpenBSD stuff
1549: .endif
1550: </pre>
1551: </li>
1552: </ol></div>
1553: </div>
1554: <div class="sect2" lang="en">
1555: <div class="titlepage"><div><div><h3 class="title">
1556: <a name="solaris"></a>3.3.7. Solaris</h3></div></div></div>
1557: <p>Solaris 2.6 through 9 are supported on both x86 and sparc.
1558: You will need a working C compiler. Both gcc 2.95.3 and
1559: Sun WorkShop 5 have been tested.</p>
1560: <p>The following packages are required on Solaris 8 for the bootstrap
1561: process and to build packages.</p>
1562: <div class="itemizedlist"><ul type="disc">
1563: <li><p>SUNWsprot</p></li>
1564: <li><p>SUNWarc</p></li>
1565: <li><p>SUNWbtool</p></li>
1566: <li><p>SUNWtoo</p></li>
1567: <li><p>SUNWlibm</p></li>
1568: </ul></div>
1569: <p>Please note that the use of GNU binutils on Solaris is
1570: <span class="emphasis"><em>not</em></span> supported, as of June 2006.</p>
1571: <p>Whichever compiler you use, please ensure the compiler tools and
1572: your $prefix are in your <code class="varname">PATH</code>. This includes
1573: <code class="filename">/usr/ccs/{bin,lib}</code>
1574: and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1575: <div class="sect3" lang="en">
1576: <div class="titlepage"><div><div><h4 class="title">
1577: <a name="solaris-gcc-note"></a>3.3.7.1. If you are using gcc</h4></div></div></div>
1578: <p>It makes life much simpler if you only use the same gcc consistently
1579: for building all packages.</p>
1580: <p>It is recommended that an external gcc be used only for bootstrapping,
1581: then either build gcc from
1582: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/lang/gcc/README.html" target="_top"><code class="filename">lang/gcc</code></a> or install a binary gcc
1583: package, then remove gcc used during bootstrapping.</p>
1.10 hubertf 1584: <p>Binary packages of gcc can be found through <a class="ulink" href="http://www.sunfreeware.com/" target="_top">http://www.sunfreeware.com/</a>.</p>
1.1 dsieger 1585: </div>
1586: <div class="sect3" lang="en">
1587: <div class="titlepage"><div><div><h4 class="title">
1588: <a name="solaris-sun-workshop-note"></a>3.3.7.2. If you are using Sun WorkShop</h4></div></div></div>
1589: <p>You will need at least the following packages installed (from WorkShop
1590: 5.0)</p>
1591: <div class="itemizedlist"><ul type="disc">
1592: <li><p>SPROcc
1593: - Sun WorkShop Compiler C 5.0</p></li>
1594: <li><p>SPROcpl
1595: - Sun WorkShop Compiler C++ 5.0</p></li>
1596: <li><p>SPROild
1597: - Sun WorkShop Incremental Linker</p></li>
1598: <li><p>SPROlang
1599: - Sun WorkShop Compilers common components</p></li>
1600: </ul></div>
1601: <p>You should set the following variables in your
1.10 hubertf 1602: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> file:</p>
1.1 dsieger 1603: <pre class="programlisting">
1604: CC= cc
1605: CXX= CC
1606: CPP= cc -E
1607: CXXCPP= CC -E
1608: </pre>
1609: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1610: <h3 class="title">Note</h3>
1611: <p>The <code class="varname">CPP</code> setting might break some
1612: packages that use the C preprocessor for processing things other
1613: than C source code.</p>
1614: </div>
1615: </div>
1616: <div class="sect3" lang="en">
1617: <div class="titlepage"><div><div><h4 class="title">
1618: <a name="solaris-sunpro-64"></a>3.3.7.3. Building 64-bit binaries with SunPro</h4></div></div></div>
1619: <p>To build 64-bit packages, you just need to have the
1.10 hubertf 1620: following lines in your <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> file:</p>
1.1 dsieger 1621: <pre class="programlisting">
1622: PKGSRC_COMPILER= sunpro
1623: ABI= 64
1624: </pre>
1625: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1626: <h3 class="title">Note</h3>
1627: <p>This setting has been tested for the SPARC
1628: architecture. Intel and AMD machines need some more
1629: work.</p>
1630: </div>
1631: </div>
1632: <div class="sect3" lang="en">
1633: <div class="titlepage"><div><div><h4 class="title">
1634: <a name="plat.sunos.problems"></a>3.3.7.4. Common problems</h4></div></div></div>
1.10 hubertf 1635: <p>Sometimes, when using <span class="command"><strong>libtool</strong></span>,
1.1 dsieger 1636: <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
1637: The workaround is to use another shell for the configure
1638: scripts, for example by installing <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/shells/bash/README.html" target="_top"><code class="filename">shells/bash</code></a> and adding the following lines
1.10 hubertf 1639: to your <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>:</p>
1.1 dsieger 1640: <pre class="programlisting">
1641: CONFIG_SHELL= ${LOCALBASE}/bin/bash
1642: WRAPPER_SHELL= ${LOCALBASE}/bin/bash
1643: </pre>
1644: <p>Then, rebuild the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/libtool-base/README.html" target="_top"><code class="filename">devel/libtool-base</code></a> package.</p>
1645: </div>
1646: </div>
1647: </div>
1648: </div>
1649: <div class="chapter" lang="en">
1650: <div class="titlepage"><div><div><h2 class="title">
1651: <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
1652: <div class="toc">
1653: <p><b>Table of Contents</b></p>
1654: <dl>
1655: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
1656: <dd><dl>
1657: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
1658: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1659: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
1660: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
1661: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
1662: <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>
1663: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
1664: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1665: </dl></dd>
1666: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
1667: <dd><dl>
1668: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
1669: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
1670: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
1671: </dl></dd>
1672: </dl>
1673: </div>
1674: <p>Basically, there are two ways of using pkgsrc. The first
1675: is to only install the package tools and to use binary packages
1676: that someone else has prepared. This is the “<span class="quote">pkg</span>”
1677: in pkgsrc. The second way is to install the “<span class="quote">src</span>”
1678: of pkgsrc, too. Then you are able to build your own packages,
1679: and you can still use binary packages from someone else.</p>
1680: <div class="sect1" lang="en">
1681: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1682: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
1.10 hubertf 1683: <p>On the <a class="ulink" href="ftp://ftp.NetBSD.org/" target="_top">ftp.NetBSD.org</a>
1.9 rillig 1684: server and its mirrors, there are collections of binary packages,
1685: ready to be installed. These binary packages have been built using the
1686: default settings for the directories, that is:</p>
1687: <div class="itemizedlist"><ul type="disc">
1688: <li><p><code class="filename">/usr/pkg</code> for <code class="varname">LOCALBASE</code>, where most of the files are installed,</p></li>
1689: <li><p><code class="filename">/usr/pkg/etc</code> for configuration files,</p></li>
1690: <li><p><code class="filename">/var</code> for <code class="varname">VARBASE</code>, where those files are installed that may change after installation.</p></li>
1691: </ul></div>
1692: <p>If you cannot use these directories for whatever reasons (maybe
1693: because you're not root), you cannot use these binary packages, but
1.10 hubertf 1694: have to build the packages yourself, which is explained in <a class="xref" href="#bootstrapping-pkgsrc" title="3.2. Bootstrapping pkgsrc">Section 3.2, “Bootstrapping pkgsrc”</a>.</p>
1.1 dsieger 1695: <div class="sect2" lang="en">
1696: <div class="titlepage"><div><div><h3 class="title">
1697: <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
1.5 weinem 1698: <p>To install binary packages, you first need to know from where
1699: to get them. The first place where you should look is on the main
1.10 hubertf 1700: pkgsrc FTP server in the directory <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/" target="_top"><code class="filename">/pub/pkgsrc/packages</code></a>.</p>
1.5 weinem 1701: <p>This directory contains binary packages for multiple
1702: platforms. First, select your operating system. (Ignore the
1703: directories with version numbers attached to it, they just exist for
1704: legacy reasons.) Then, select your hardware architecture, and in the
1.9 rillig 1705: third step, the OS version and the “<span class="quote">version</span>” of pkgsrc.</p>
1706: <p>In this directory, you often find a file called
1707: <code class="filename">bootstrap.tar.gz</code> which contains the package
1708: management tools. If the file is missing, it is likely that your
1709: operating system already provides those tools. Download the file and
1710: extract it in the <code class="filename">/</code> directory. It will create
1711: the directories <code class="filename">/usr/pkg</code> (containing the tools
1712: for managing binary packages) and <code class="filename">/var/db/pkg</code>
1713: (the database of installed packages).</p>
1.1 dsieger 1714: </div>
1715: <div class="sect2" lang="en">
1716: <div class="titlepage"><div><div><h3 class="title">
1717: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
1.9 rillig 1718: <p>In the directory from the last section, there is a
1719: subdirectory called <code class="filename">All</code>, which contains all the
1720: binary packages that are available for the platform, excluding those
1721: that may not be distributed via FTP or CDROM (depending on which
1722: medium you are using), and the ones that have vulnerabilities and
1723: therefore are considered insecure to install without thinking
1724: before.</p>
1725: <p>To install packages directly from an FTP or HTTP server, run
1726: the following commands in a Bourne-compatible shell (be sure to
1.10 hubertf 1727: <span class="command"><strong>su</strong></span> to root first):</p>
1.9 rillig 1728: <pre class="screen">
1729: <code class="prompt">#</code> <strong class="userinput"><code>PATH="/usr/pkg/sbin:$PATH"</code></strong>
1730: <code class="prompt">#</code> <strong class="userinput"><code>PKG_PATH="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/<em class="replaceable"><code>OPSYS</code></em>/<em class="replaceable"><code>ARCH</code></em>/<em class="replaceable"><code>VERSIONS</code></em>/All"</code></strong>
1731: <code class="prompt">#</code> <strong class="userinput"><code>export PATH PKG_PATH</code></strong>
1732: </pre>
1733: <p>Instead of URLs, you can also use local paths, for example if
1734: you are installing from a set of CDROMs, DVDs or an NFS-mounted
1735: repository. If you want to install packages from multiple sources,
1736: you can separate them by a semicolon in
1737: <code class="varname">PKG_PATH</code>.</p>
1738: <p>After these preparations, installing a package is very
1739: easy:</p>
1740: <pre class="screen">
1741: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add openoffice2</code></strong>
1742: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add kde-3.5.7</code></strong>
1743: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add ap2-php5-*</code></strong>
1744: </pre>
1.1 dsieger 1745: <p>Note that any prerequisite packages needed to run the
1746: package in question will be installed, too, assuming they are
1747: present where you install from.</p>
1.9 rillig 1748: <p>As mentioned above, packages for which vulnerabilities get
1749: known are not stored in the <code class="filename">All</code> subdirectory.
1750: They don't get deleted since that could be very frustrating if many
1751: other packages depend on it. Instead, they are moved to the
1752: <code class="filename">vulnerable</code> subdirectory. So you may need to add
1753: this directory to the <code class="varname">PKG_PATH</code> variable.
1.14 ! jmcneill 1754: However, you should run <span class="command"><strong>audit-packages</strong></span>
! 1755: regularly, especially after installing new packages, and verify
! 1756: that the vulnerabilities are acceptable for your configuration.</p>
1.1 dsieger 1757: <p>After you've installed packages, be sure to have
1758: <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
1759: <code class="varname">PATH</code> so you can actually start the just
1760: installed program.</p>
1761: </div>
1762: <div class="sect2" lang="en">
1763: <div class="titlepage"><div><div><h3 class="title">
1764: <a name="using.pkg_delete"></a>4.1.3. Deinstalling packages</h3></div></div></div>
1765: <p>To deinstall a package, it does not matter whether it was
1766: installed from source code or from a binary package. The
1.10 hubertf 1767: <span class="command"><strong>pkg_delete</strong></span> command does not know it anyway.
1768: To delete a package, you can just run <span class="command"><strong>pkg_delete
1.1 dsieger 1769: <em class="replaceable"><code>package-name</code></em></strong></span>. The package
1770: name can be given with or without version number. Wildcards can
1771: also be used to deinstall a set of packages, for example
1772: <code class="literal">*emacs*</code>. Be sure to include them in quotes,
1773: so that the shell does not expand them before
1774: <code class="literal">pkg_delete</code> sees them.</p>
1775: <p>The <code class="option">-r</code> option is very powerful: it
1776: removes all the packages that require the package in question
1777: and then removes the package itself. For example:
1778:
1779: </p>
1780: <pre class="screen">
1781: <code class="prompt">#</code> <strong class="userinput"><code>pkg_delete -r jpeg</code></strong>
1782: </pre>
1783: <p>
1784:
1785: will remove jpeg and all the packages that used it; this allows
1786: upgrading the jpeg package.</p>
1787: </div>
1788: <div class="sect2" lang="en">
1789: <div class="titlepage"><div><div><h3 class="title">
1790: <a name="using.pkg_info"></a>4.1.4. Getting information about installed packages</h3></div></div></div>
1.10 hubertf 1791: <p>The <span class="command"><strong>pkg_info</strong></span> shows information about
1.1 dsieger 1792: installed packages or binary package files.</p>
1793: </div>
1794: <div class="sect2" lang="en">
1795: <div class="titlepage"><div><div><h3 class="title">
1796: <a name="vulnerabilities"></a>4.1.5. Checking for security vulnerabilities in installed packages</h3></div></div></div>
1797: <p>
1798: The NetBSD Security-Officer and Packages Groups maintain a list of
1799: known security vulnerabilities to packages which are (or have been)
1800: included in pkgsrc. The list is available from the NetBSD
1.10 hubertf 1801: FTP site at <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities</a>.
1.1 dsieger 1802: </p>
1803: <p>
1804: Through <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>,
1805: this list can be downloaded
1806: automatically, and a security audit of all packages installed on a system
1807: can take place.
1808: </p>
1809: <p>
1810: There are two components to
1811: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>. The first
1812: component, “<span class="quote">download-vulnerability-list</span>”, is for downloading
1813: the list of vulnerabilities from the NetBSD FTP site. The second
1814: component, “<span class="quote">audit-packages</span>”, checks to see if any of your
1815: installed packages are vulnerable. If a package is vulnerable, you
1816: will see output similar to the following:
1817: </p>
1818: <pre class="screen">Package samba-2.0.9 has a local-root-shell vulnerability, see
1819: http://www.samba.org/samba/whatsnew/macroexploit.html</pre>
1820: <p>
1821: One can set up <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a> to download the
1.10 hubertf 1822: <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">vulnerabilities</a>
1.1 dsieger 1823: file daily, and include a package audit in the daily security script.
1.10 hubertf 1824: Details on this are located in the <a class="ulink" href="http://cvsweb.NetBSD.org/bsdweb.cgi/pkgsrc/security/audit-packages/MESSAGE?rev=HEAD&content-type=text/x-cvsweb-markup" target="_top">MESSAGE</a>
1.1 dsieger 1825: file for <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>.
1826: </p>
1827: </div>
1828: <div class="sect2" lang="en">
1829: <div class="titlepage"><div><div><h3 class="title">
1830: <a name="pkg_versions"></a>4.1.6. Finding if newer versions of your installed packages are in pkgsrc</h3></div></div></div>
1831: <p>
1.12 weinem 1832: Install <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/lintpkgsrc/README.html" target="_top"><code class="filename">pkgtools/lintpkgsrc</code></a> and run
1.10 hubertf 1833: <span class="command"><strong>lintpkgsrc</strong></span> with the “<span class="quote">-i</span>”
1.1 dsieger 1834: argument to check if your packages are up-to-date, e.g.
1835: </p>
1836: <pre class="screen">
1837: <code class="prompt">%</code> <strong class="userinput"><code>lintpkgsrc -i</code></strong>
1838: ...
1839: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
1840: </pre>
1.10 hubertf 1841: <p>You can then use <span class="command"><strong>make update</strong></span> to update the
1.1 dsieger 1842: package on your system and rebuild any dependencies.
1843: </p>
1844: </div>
1845: <div class="sect2" lang="en">
1846: <div class="titlepage"><div><div><h3 class="title">
1847: <a name="using.pkg_admin"></a>4.1.7. Other administrative functions</h3></div></div></div>
1.10 hubertf 1848: <p>The <span class="command"><strong>pkg_admin</strong></span> executes various
1.1 dsieger 1849: administrative functions on the package system.</p>
1850: </div>
1851: <div class="sect2" lang="en">
1852: <div class="titlepage"><div><div><h3 class="title">
1853: <a name="a-word-of-warning"></a>4.1.8. A word of warning</h3></div></div></div>
1854: <p>Please pay very careful attention to the warnings
1.10 hubertf 1855: expressed in the <a class="citerefentry" 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
1.1 dsieger 1856: inherent dangers of installing binary packages which you did
1857: not create yourself, and the security holes that can be
1858: introduced onto your system by indiscriminate adding of such
1859: files.</p>
1860: <p>The same warning of course applies to every package you
1861: install from source when you haven't completely read and
1862: understood the source code of the package, the compiler that
1863: is used to build the package and all the other tools that are
1864: involved.</p>
1865: </div>
1866: </div>
1867: <div class="sect1" lang="en">
1868: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1869: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
1870: <p>After obtaining pkgsrc, the <code class="filename">pkgsrc</code>
1871: directory now contains a set of packages, organized into
1872: categories. You can browse the online index of packages, or run
1.10 hubertf 1873: <span class="command"><strong>make readme</strong></span> from the <code class="filename">pkgsrc</code>
1.1 dsieger 1874: directory to build local <code class="filename">README.html</code> files for
1875: all packages, viewable with any web browser such as <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/lynx/README.html" target="_top"><code class="filename">www/lynx</code></a> or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a>.</p>
1876: <p>The default <span class="emphasis"><em>prefix</em></span> for installed packages
1877: is <code class="filename">/usr/pkg</code>. If you wish to change this, you
1878: should do so by setting <code class="varname">LOCALBASE</code> in
1.10 hubertf 1879: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>. You should not try to use multiple
1.1 dsieger 1880: different <code class="varname">LOCALBASE</code> definitions on the same
1881: system (inside a chroot is an exception). </p>
1882: <p>The rest of this chapter assumes that the package is already
1.10 hubertf 1883: in pkgsrc. If it is not, see <a class="xref" href="#developers-guide" title="Part II. The pkgsrc developer's guide">Part II, “The pkgsrc developer's guide”</a> for
1.1 dsieger 1884: instructions how to create your own packages.</p>
1885: <div class="sect2" lang="en">
1886: <div class="titlepage"><div><div><h3 class="title">
1887: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
1888: <p>To build packages from source, you need a working C
1889: compiler. On NetBSD, you need to install the
1890: “<span class="quote">comp</span>” and the “<span class="quote">text</span>” distribution
1891: sets. If you want to build X11-related packages, the
1892: “<span class="quote">xbase</span>” and “<span class="quote">xcomp</span>” distribution
1893: sets are required, too.</p>
1894: </div>
1895: <div class="sect2" lang="en">
1896: <div class="titlepage"><div><div><h3 class="title">
1897: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
1898: <p>The first step for building a package is downloading the
1899: distfiles (i.e. the unmodified source). If they have not yet been
1900: downloaded, pkgsrc will fetch them automatically.</p>
1901: <p>If you have all files that you need in the
1902: <code class="filename">distfiles</code> directory,
1903: you don't need to connect. If the distfiles are on CD-ROM, you can
1904: mount the CD-ROM on <code class="filename">/cdrom</code> and add:
1905: </p>
1906: <pre class="screen">DISTDIR=/cdrom/pkgsrc/distfiles</pre>
1907: <p>
1.10 hubertf 1908: to your <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.</p>
1.1 dsieger 1909: <p>By default a list of distribution sites will be randomly
1910: intermixed to prevent huge load on servers which holding popular
1911: packages (for example, SourceForge.net mirrors). Thus, every
1912: time when you need to fetch yet another distfile all the mirrors
1913: will be tried in new (random) order. You can turn this feature
1914: off by setting <code class="varname">MASTER_SORT_RANDOM=NO</code> (for
1915: <code class="varname">PKG_DEVELOPER</code>s it's already disabled).</p>
1916: <p>You can overwrite some of the major distribution sites to
1917: fit to sites that are close to your own. By setting one or two
1918: variables you can modify the order in which the master sites are
1919: accessed. <code class="varname">MASTER_SORT</code> contains a whitespace
1920: delimited list of domain suffixes.
1921: <code class="varname">MASTER_SORT_REGEX</code> is even more flexible, it
1922: contains a whitespace delimited list of regular expressions. It
1923: has higher priority than <code class="varname">MASTER_SORT</code>. Have a
1924: look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find
1925: some examples. This may save some of your bandwidth and
1926: time.</p>
1927: <p>You can change these settings either in your shell's environment, or,
1928: if you want to keep the settings, by editing the
1.10 hubertf 1929: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> file,
1.1 dsieger 1930: and adding the definitions there.</p>
1931: <p>
1932: If a package depends on many other packages (such as
1933: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/kde3/README.html" target="_top"><code class="filename">meta-pkgs/kde3</code></a>), the build process may
1934: alternate between periods of
1935: downloading source, and compiling. To ensure you have all the source
1936: downloaded initially you can run the command:
1937: </p>
1938: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch-list | sh</code></strong></pre>
1939: <p>
1940: which will output and run a set of shell commands to fetch the
1941: necessary files into the <code class="filename">distfiles</code> directory. You can
1942: also choose to download the files manually.
1943: </p>
1944: </div>
1945: <div class="sect2" lang="en">
1946: <div class="titlepage"><div><div><h3 class="title">
1947: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
1948: <p>
1949: Once the software has downloaded, any patches will be applied, then it
1950: will be compiled for you. This may take some time depending on your
1951: computer, and how many other packages the software depends on and their
1952: compile time.
1953: </p>
1954: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1955: <h3 class="title">Note</h3>
1956: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
1.10 hubertf 1957: use the pkgsrc <span class="command"><strong>bmake</strong></span> command instead of
1.1 dsieger 1958: “<span class="quote">make</span>” in the examples in this guide.</p>
1959: </div>
1960: <p>For example, type</p>
1961: <pre class="screen">
1962: <code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
1963: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
1964: </pre>
1965: <p>at the shell prompt to build the various components of the
1966: package.</p>
1967: <p>The next stage is to actually install the newly compiled
1968: program onto your system. Do this by entering:
1969:
1970: </p>
1971: <pre class="screen">
1972: <code class="prompt">%</code> <strong class="userinput"><code>make install</code></strong>
1973: </pre>
1974: <p>
1975:
1976: while you are still in the directory for whatever package you
1977: are installing.</p>
1978: <p>Installing the package on your system may require you to
1979: be root. However, pkgsrc has a
1980: <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
1981: to only become root for the actual installation step.</p>
1982: <p>That's it, the software should now be installed and setup for use.
1983: You can now enter:
1984:
1985: </p>
1986: <pre class="screen">
1987: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong>
1988: </pre>
1989: <p>
1990:
1991: to remove the compiled files in the work directory, as you shouldn't need
1992: them any more. If other packages were also added to your system
1993: (dependencies) to allow your program to compile, you can tidy these up
1994: also with the command:</p>
1995: <pre class="screen">
1996: <code class="prompt">%</code> <strong class="userinput"><code>make clean-depends</code></strong>
1997: </pre>
1998: <p>Taking the figlet utility as an example, we can install it on our
1.10 hubertf 1999: system by building as shown in <a class="xref" href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
1.1 dsieger 2000: <p>The program is installed under the default root of the
2001: packages tree - <code class="filename">/usr/pkg</code>. Should this not
2002: conform to your tastes, set the <code class="varname">LOCALBASE</code>
2003: variable in your environment, and it will use that value as the
2004: root of your packages tree. So, to use
2005: <code class="filename">/usr/local</code>, set
2006: <code class="varname">LOCALBASE=/usr/local</code> in your environment.
2007: Please note that you should use a directory which is dedicated to
2008: packages and not shared with other programs (i.e., do not try and
2009: use <code class="varname">LOCALBASE=/usr</code>). Also, you should not try
2010: to add any of your own files or directories (such as
2011: <code class="filename">src/</code>, <code class="filename">obj/</code>, or
2012: <code class="filename">pkgsrc/</code>) below the
2013: <code class="varname">LOCALBASE</code> tree. This is to prevent possible
2014: conflicts between programs and other files installed by the
2015: package system and whatever else may have been installed
2016: there.</p>
1.10 hubertf 2017: <p>Some packages look in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> to
1.1 dsieger 2018: alter some configuration options at build time. Have a look at
2019: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to get an overview
2020: of what will be set there by default. Environment variables such
2021: as <code class="varname">LOCALBASE</code> can be set in
1.10 hubertf 2022: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> to save having to remember to
1.1 dsieger 2023: set them each time you want to use pkgsrc.</p>
2024: <p>Occasionally, people want to “<span class="quote">look under the
2025: covers</span>” to see what is going on when a package is building
2026: or being installed. This may be for debugging purposes, or out of
2027: simple curiosity. A number of utility values have been added to
2028: help with this.</p>
2029: <div class="orderedlist"><ol type="1">
2030: <li>
1.10 hubertf 2031: <p>If you invoke the <a class="citerefentry" 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
1.1 dsieger 2032: <code class="varname">PKG_DEBUG_LEVEL=2</code>, then a huge amount of
2033: information will be displayed. For example,</p>
2034: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
2035: <p>will show all the commands that are invoked, up to and
2036: including the “<span class="quote">patch</span>” stage.</p>
2037: </li>
2038: <li>
1.10 hubertf 2039: <p>If you want to know the value of a certain <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>
1.1 dsieger 2040: definition, then the <code class="varname">VARNAME</code> definition
2041: should be used, in conjunction with the show-var
1.10 hubertf 2042: target. e.g. to show the expansion of the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>
1.1 dsieger 2043: variable <code class="varname">LOCALBASE</code>:</p>
2044: <pre class="screen">
2045: <code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
2046: /usr/pkg
2047: <code class="prompt">%</code>
2048: </pre>
2049: </li>
2050: </ol></div>
2051: <p>If you want to install a binary package that you've either
2052: created yourself (see next section), that you put into
2053: pkgsrc/packages manually or that is located on a remote FTP
2054: server, you can use the "bin-install" target. This target will
1.10 hubertf 2055: install a binary package - if available - via <a class="citerefentry" 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>,
2056: else do a <span class="command"><strong>make package</strong></span>. The list of remote FTP
1.1 dsieger 2057: sites searched is kept in the variable
2058: <code class="varname">BINPKG_SITES</code>, which defaults to
1.10 hubertf 2059: ftp.NetBSD.org. Any flags that should be added to <a class="citerefentry" 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.1 dsieger 2060: can be put into <code class="varname">BIN_INSTALL_FLAGS</code>. See
2061: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more
2062: details.</p>
2063: <p>A final word of warning: If you set up a system that has a
2064: non-standard setting for <code class="varname">LOCALBASE</code>, be sure to
2065: set that before any packages are installed, as you cannot use
2066: several directories for the same purpose. Doing so will result in
2067: pkgsrc not being able to properly detect your installed packages,
2068: and fail miserably. Note also that precompiled binary packages are
2069: usually built with the default <code class="varname">LOCALBASE</code> of
2070: <code class="filename">/usr/pkg</code>, and that you should
2071: <span class="emphasis"><em>not</em></span> install any if you use a non-standard
2072: <code class="varname">LOCALBASE</code>.</p>
2073: </div>
2074: </div>
2075: </div>
2076: <div class="chapter" lang="en">
2077: <div class="titlepage"><div><div><h2 class="title">
2078: <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
2079: <div class="toc">
2080: <p><b>Table of Contents</b></p>
2081: <dl>
2082: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
2083: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.9 rillig 2084: <dt><span class="sect1"><a href="#variables-affecting-installation">5.3. Variables affecting the installation process</a></span></dt>
1.4 rillig 2085: <dt><span class="sect1"><a href="#conf.compiler">5.4. Selecting and configuring the compiler</a></span></dt>
1.1 dsieger 2086: <dd><dl>
1.4 rillig 2087: <dt><span class="sect2"><a href="#selecting-the-compiler">5.4.1. Selecting the compiler</a></span></dt>
2088: <dt><span class="sect2"><a href="#conf.cflags">5.4.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
2089: <dt><span class="sect2"><a href="#conf.ldflags">5.4.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
1.1 dsieger 2090: </dl></dd>
1.4 rillig 2091: <dt><span class="sect1"><a href="#developer-advanced-settings">5.5. Developer/advanced settings</a></span></dt>
2092: <dt><span class="sect1"><a href="#selecting-build-options">5.6. Selecting Build Options</a></span></dt>
1.1 dsieger 2093: </dl>
2094: </div>
1.4 rillig 2095: <a name="mk.conf"></a><p>The whole pkgsrc system is configured in a single file, usually
1.1 dsieger 2096: called <code class="filename">mk.conf</code>. In which directory pkgsrc looks for
2097: that file depends on the installation. On NetBSD, when you use
1.10 hubertf 2098: <a class="citerefentry" 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
1.1 dsieger 2099: <code class="filename">/etc/</code>. In all other cases the default location is
2100: <code class="literal">${PREFIX}/etc/</code>, depending on where you told the
2101: bootstrap program to install the binary packages.</p>
2102: <p>During the bootstrap, an example configuration file is created. To
2103: use that, you have to create the directory
2104: <code class="filename">${PREFIX}/etc</code> and copy the example file
2105: there.</p>
2106: <p>The format of the configuration file is that of the usual
2107: BSD-style <code class="filename">Makefile</code>s. The whole pkgsrc configuration
2108: is done by setting variables in this file. Note that you can define all
2109: kinds of variables, and no special error checking (for example for
2110: spelling mistakes) takes place, so you have to try it out to see if it
2111: works.</p>
2112: <div class="sect1" lang="en">
2113: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2114: <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
2115: <p>In this section, you can find some variables that apply to all
2116: pkgsrc packages. A complete list of the variables that can be
2117: configured by the user is available in
2118: <code class="filename">mk/defaults/mk.conf</code>, together with some
2119: comments that describe each variable's intent.</p>
2120: <div class="itemizedlist"><ul type="disc">
2121: <li><p><code class="varname">LOCALBASE</code>: Where
2122: packages will be installed. The default is
2123: <code class="filename">/usr/pkg</code>. Do not mix binary packages
2124: with different <code class="varname">LOCALBASE</code>s!</p></li>
2125: <li><p><code class="varname">CROSSBASE</code>: Where
2126: “<span class="quote">cross</span>” category packages will be
2127: installed. The default is
2128: <code class="filename">${LOCALBASE}/cross</code>.</p></li>
2129: <li><p><code class="varname">X11BASE</code>: Where
2130: X11 is installed on the system. The default is
2131: <code class="filename">/usr/X11R6</code>.</p></li>
2132: <li><p><code class="varname">DISTDIR</code>: Where to store the
2133: downloaded copies of the original source distributions used
2134: for building pkgsrc packages. The default is
2135: <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
2136: <li><p><code class="varname">PKG_DBDIR</code>: Where the
2137: database about installed packages is stored. The default is
2138: <code class="filename">/var/db/pkg</code>.</p></li>
2139: <li><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
2140: If set, override the packages'
2141: <code class="varname">MASTER_SITES</code> with this value.</p></li>
2142: <li><p><code class="varname">MASTER_SITE_BACKUP</code>:
2143: Backup location(s) for distribution files and patch files
2144: if not found locally or in
2145: <code class="filename">${MASTER_SITES}</code> or
2146: <code class="filename">${PATCH_SITES}</code> respectively.
2147: The defaults are
2148: <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
2149: and
2150: <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
2151: <li><p><code class="varname">BINPKG_SITES</code>:
2152: List of sites carrying binary pkgs. <em class="replaceable"><code>rel</code></em> and
2153: <em class="replaceable"><code>arch</code></em> are replaced with OS
2154: release (“<span class="quote">2.0</span>”, etc.) and architecture
2155: (“<span class="quote">mipsel</span>”, etc.).</p></li>
2156: <li><p><code class="varname">ACCEPTABLE_LICENSES</code>:
2157: List of acceptable licenses. Whenever you try to build a package
2158: whose license is not in this list, you will get an error message
2159: that includes instructions on how to change this variable.</p></li>
2160: </ul></div>
2161: </div>
2162: <div class="sect1" lang="en">
2163: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2164: <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
2165: <p>XXX
2166: </p>
2167: <div class="itemizedlist"><ul type="disc">
2168: <li><p><code class="varname">PACKAGES</code>: The top level
2169: directory for the binary packages. The default is
2170: <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
2171: <li><p><code class="varname">WRKOBJDIR</code>:
2172: The top level directory where, if defined, the separate
2173: working directories will get created, and symbolically
2174: linked to from <code class="filename">${WRKDIR}</code> (see below).
2175: This is useful for building packages on several
2176: architectures, then <code class="filename">${PKGSRCDIR}</code>
2177: can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
2178: is local to every architecture. (It should be noted that
2179: <code class="varname">PKGSRCDIR</code> should not be set by the user
1.14 ! jmcneill 2180: — it is an internal definition which refers to the
1.1 dsieger 2181: root of the pkgsrc tree. It is possible to have many
2182: pkgsrc tree instances.)</p></li>
2183: <li><p><code class="varname">LOCALPATCHES</code>:
2184: Directory for local patches that aren't part of pkgsrc.
1.10 hubertf 2185: See <a class="xref" href="#components.patches" title="11.3. patches/*">Section 11.3, “patches/*”</a> for more
1.1 dsieger 2186: information.</p></li>
2187: <li><p><code class="varname">PKGMAKECONF</code>: Location of
1.10 hubertf 2188: the <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> file used by a package's
1.1 dsieger 2189: BSD-style Makefile. If this is not set,
2190: <code class="varname">MAKECONF</code> is set to
2191: <code class="filename">/dev/null</code> to avoid picking up
2192: settings used by builds in <code class="filename">/usr/src</code>.</p></li>
2193: <li><p><code class="varname">DEPENDS_TARGET</code>:
2194: By default, dependencies are only installed, and no binary
2195: package is created for them. You can set this variable to
2196: <code class="literal">package</code> to automatically create binary
2197: packages after installing dependencies.</p></li>
2198: </ul></div>
2199: </div>
2200: <div class="sect1" lang="en">
2201: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.9 rillig 2202: <a name="variables-affecting-installation"></a>5.3. Variables affecting the installation process</h2></div></div></div>
1.4 rillig 2203: <p>A growing number of packages support installation into a
2204: subdirectory of <code class="varname">WRKDIR</code>. This allows a package
2205: to be built, before the actual filesystem is touched. DESTDIR
2206: support exists in two variations:</p>
2207: <div class="itemizedlist"><ul type="disc">
2208: <li><p>Basic DESTDIR support means that the package
2209: installation and packaging is still run as
2210: root.</p></li>
2211: <li><p>Full DESTDIR support can run the complete build,
2212: installation and packaging as normal user. Root privileges are
2213: only needed to add packages.</p></li>
2214: </ul></div>
2215: <p>To use the DESTDIR support, set either
2216: <code class="varname">USE_DESTDIR=yes</code> to use the basic support for
2217: packages that offer it or <code class="varname">USE_DESTDIR=full</code> to
2218: get the full support with fallback to basic
2219: support. <code class="varname">USE_DESTDIR=full</code> needs <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a> version 20070802 (or
2220: newer). It might become the default DESTDIR support later.</p>
2221: <p>DESTDIR support changes the behaviour of various targets
2222: slightly. To install a package after building it, use
2223: <code class="literal">package-install</code>. <code class="literal">package</code> and
2224: <code class="literal">install</code> don't do that any
2225: longer. <code class="literal">package-install</code> can be used as
2226: <code class="varname">DEPENDS_TARGET</code>. <code class="literal">bin-install</code>
2227: will ask for the root password to install the package and fail,
2228: <code class="literal">package-install</code> will ask again.</p>
2229: <p>With basic DESTDIR support, <strong class="userinput"><code>make
2230: clean</code></strong> needs to be run as root.</p>
2231: </div>
2232: <div class="sect1" lang="en">
2233: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2234: <a name="conf.compiler"></a>5.4. Selecting and configuring the compiler</h2></div></div></div>
1.1 dsieger 2235: <div class="sect2" lang="en">
2236: <div class="titlepage"><div><div><h3 class="title">
1.4 rillig 2237: <a name="selecting-the-compiler"></a>5.4.1. Selecting the compiler</h3></div></div></div>
1.1 dsieger 2238: <p>By default, pkgsrc will use GCC to build packages. This may be
2239: overridden by setting the following variables in /etc/mk.conf:</p>
2240: <div class="variablelist"><dl>
2241: <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
2242: <dd>
2243: <p>This is a list of values specifying the chain of
2244: compilers to invoke when building packages. Valid values
2245: are:</p>
2246: <div class="itemizedlist"><ul type="disc">
2247: <li><p><code class="varname">distcc</code>:
2248: distributed C/C++ (chainable)</p></li>
2249: <li><p><code class="varname">ccache</code>:
2250: compiler cache (chainable)</p></li>
2251: <li><p><code class="varname">gcc</code>:
2252: GNU C/C++ Compiler</p></li>
2253: <li><p><code class="varname">mipspro</code>:
2254: Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
2255: <li><p><code class="varname">mipspro</code>:
2256: Silicon Graphics, Inc. MIPSpro (o32)</p></li>
2257: <li><p><code class="varname">sunpro</code>:
2258: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
2259: </ul></div>
2260: <p>The default is
2261: “<span class="quote"><code class="varname">gcc</code></span>”. You can use
2262: <code class="varname">ccache</code> and/or
2263: <code class="varname">distcc</code> with an appropriate
2264: <code class="varname">PKGSRC_COMPILER</code> setting,
2265: e.g. “<span class="quote"><code class="varname">ccache gcc</code></span>”. This
2266: variable should always be terminated with a value for
2267: a real compiler. Note that only one real compiler
2268: should be listed (e.g. “<span class="quote"><code class="varname">sunpro gcc</code></span>”
2269: is not allowed).</p>
2270: </dd>
2271: <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
2272: <dd><p>This specifies the minimum version of GCC to use
2273: when building packages. If the system GCC doesn't
2274: satisfy this requirement, then pkgsrc will build and
2275: install one of the GCC packages to use instead.</p></dd>
2276: </dl></div>
2277: </div>
2278: <div class="sect2" lang="en">
2279: <div class="titlepage"><div><div><h3 class="title">
1.4 rillig 2280: <a name="conf.cflags"></a>5.4.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</h3></div></div></div>
1.1 dsieger 2281: <p>If you wish to set the <code class="varname">CFLAGS</code> variable,
2282: please make sure to use the <code class="literal">+=</code> operator
2283: instead of the <code class="literal">=</code> operator:</p>
2284: <pre class="programlisting">
2285: CFLAGS+= -your -flags
2286: </pre>
2287: <p>Using <code class="varname">CFLAGS=</code> (i.e. without the
2288: “<span class="quote">+</span>”) may lead to problems with packages that need
2289: to add their own flags. Also, you may want to take a look at
2290: the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/cpuflags/README.html" target="_top"><code class="filename">devel/cpuflags</code></a> package if
2291: you're interested in optimization for the current CPU.</p>
2292: </div>
2293: <div class="sect2" lang="en">
2294: <div class="titlepage"><div><div><h3 class="title">
1.4 rillig 2295: <a name="conf.ldflags"></a>5.4.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</h3></div></div></div>
1.1 dsieger 2296: <p>If you want to pass flags to the linker, both in the configure
2297: step and the build step, you can do this in two ways. Either set
2298: <code class="varname">LDFLAGS</code> or <code class="varname">LIBS</code>. The difference
2299: between the two is that <code class="varname">LIBS</code> will be appended to
2300: the command line, while <code class="varname">LDFLAGS</code> come earlier.
2301: <code class="varname">LDFLAGS</code> is pre-loaded with rpath settings for ELF
2302: machines depending on the setting of <code class="varname">USE_IMAKE</code> or
2303: the inclusion of <code class="filename">mk/x11.buildlink3.mk</code>. As with
2304: <code class="varname">CFLAGS</code>, if you do not wish to override these
2305: settings, use the <code class="literal">+=</code> operator:</p>
2306: <pre class="programlisting">
2307: LDFLAGS+= -your -linkerflags
2308: </pre>
2309: </div>
2310: </div>
2311: <div class="sect1" lang="en">
2312: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.4 rillig 2313: <a name="developer-advanced-settings"></a>5.5. Developer/advanced settings</h2></div></div></div>
1.1 dsieger 2314: <p>XXX
2315: </p>
2316: <div class="itemizedlist"><ul type="disc">
2317: <li>
2318: <p><code class="varname">PKG_DEVELOPER</code>:
2319: Run some sanity checks that package developers want:
2320: </p>
2321: <div class="itemizedlist"><ul type="circle">
2322: <li><p>make sure patches apply with zero
2323: fuzz</p></li>
2324: <li><p>run check-shlibs to see that all
2325: binaries will find their shared libs.</p></li>
2326: </ul></div>
2327: <p>
2328: </p>
2329: </li>
2330: <li><p><code class="varname">PKG_DEBUG_LEVEL</code>: The level
2331: of debugging output which is displayed whilst making and
2332: installing the package. The default value for this is 0,
2333: which will not display the commands as they are executed
2334: (normal, default, quiet operation); the value 1 will display
2335: all shell commands before their invocation, and the value 2
2336: will display both the shell commands before their invocation,
1.10 hubertf 2337: and their actual execution progress with <span class="command"><strong>set
1.1 dsieger 2338: -x</strong></span> will be displayed.</p></li>
2339: </ul></div>
2340: <p>
2341: </p>
2342: </div>
2343: <div class="sect1" lang="en">
2344: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.4 rillig 2345: <a name="selecting-build-options"></a>5.6. Selecting Build Options</h2></div></div></div>
1.1 dsieger 2346: <p>Some packages have build time options, usually to select
2347: between different dependencies, enable optional support for big
2348: dependencies or enable experimental features.</p>
2349: <p>To see which options, if any, a package supports, and which
1.10 hubertf 2350: options are mutually exclusive, run <span class="command"><strong>make
1.1 dsieger 2351: show-options</strong></span>, for example:</p>
2352: <pre class="programlisting">
2353: The following options are supported by this package:
2354: ssl Enable SSL support.
2355: Exactly one of the following gecko options is required:
2356: firefox Use firefox as gecko rendering engine.
2357: mozilla Use mozilla as gecko rendering engine.
2358: At most one of the following database options may be selected:
2359: mysql Enable support for MySQL database.
2360: pgsql Enable support for PostgreSQL database.
2361:
2362: These options are enabled by default: firefox
2363: These options are currently enabled: mozilla ssl
2364: </pre>
2365: <p>The following variables can be defined in
1.10 hubertf 2366: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> to select which options to
1.1 dsieger 2367: enable for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>,
2368: which can be used to select or disable options for all packages
2369: that support them, and
2370: <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
2371: which can be used to select or disable options specifically for
2372: package <em class="replaceable"><code>pkgbase</code></em>. Options listed in
2373: these variables are selected, options preceded by “<span class="quote">-</span>”
2374: are disabled. A few examples:</p>
2375: <pre class="screen">
1.10 hubertf 2376: <code class="prompt">$</code> <span class="command"><strong>grep "PKG.*OPTION" <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a></strong></span>
1.1 dsieger 2377: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
2378: PKG_OPTIONS.kdebase= debug -sasl
2379: PKG_OPTIONS.apache= suexec </pre>
1.11 rillig 2380: <p>It is important to note that options that were specifically
2381: suggested by the package maintainer must be explicitely removed if
2382: you do not wish to include the option. If you are unsure you can view
2383: the current state with <span class="command"><strong>make show-options</strong></span>.</p>
1.1 dsieger 2384: <p>The following settings are consulted in the order given, and
2385: the last setting that selects or disables an option is
2386: used:</p>
2387: <div class="orderedlist"><ol type="1">
2388: <li><p>the default options as suggested by the package
2389: maintainer</p></li>
2390: <li><p>the options implied by the settings of legacy
2391: variables (see below)</p></li>
2392: <li><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
2393: <li><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
2394: </ol></div>
2395: <p>For groups of mutually exclusive options, the last option
2396: selected is used, all others are automatically disabled. If an
2397: option of the group is explicitly disabled, the previously
2398: selected option, if any, is used. It is an error if no option
2399: from a required group of options is selected, and building the
2400: package will fail.</p>
2401: <p>Before the options framework was introduced, build options
2402: were selected by setting a variable (often named
2403: <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
1.10 hubertf 2404: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> for each option. To ease
1.1 dsieger 2405: transition to the options framework for the user, these legacy
2406: variables are converted to the appropriate options setting
2407: (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
2408: automatically. A warning is issued to prompt the user to update
1.10 hubertf 2409: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> to use the options framework
1.1 dsieger 2410: directly. Support for the legacy variables will be removed
2411: eventually.</p>
2412: </div>
2413: </div>
2414: <div class="chapter" lang="en">
2415: <div class="titlepage"><div><div><h2 class="title">
2416: <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
2417: <div class="toc">
2418: <p><b>Table of Contents</b></p>
2419: <dl>
2420: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
2421: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
2422: </dl>
2423: </div>
2424: <div class="sect1" lang="en">
2425: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2426: <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
2427: <p>Once you have built and installed a package, you can create
2428: a <span class="emphasis"><em>binary package</em></span> which can be installed on
1.10 hubertf 2429: another system with <a class="citerefentry" 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
1.1 dsieger 2430: the same package on a group of hosts and wasting CPU time. It also
2431: provides a simple means for others to install your package, should
2432: you distribute it.</p>
2433: <p>To create a binary package, change into the appropriate
1.10 hubertf 2434: directory in pkgsrc, and run <span class="command"><strong>make
1.1 dsieger 2435: package</strong></span>:</p>
2436: <pre class="screen">
2437: <code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
2438: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
2439: </pre>
2440: <p>This will build and install your package (if not already done),
2441: and then build a binary package from what was installed. You can
1.10 hubertf 2442: then use the <span class="command"><strong>pkg_*</strong></span> tools to manipulate
1.1 dsieger 2443: it. Binary packages are created by default in
2444: <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
1.10 hubertf 2445: gzipped tar file. See <a class="xref" href="#logs.package" title="B.2. Packaging figlet">Section B.2, “Packaging figlet”</a> for a
1.1 dsieger 2446: continuation of the above <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/misc/figlet/README.html" target="_top"><code class="filename">misc/figlet</code></a> example.</p>
1.10 hubertf 2447: <p>See <a class="xref" href="#submit" title="Chapter 21. Submitting and Committing">Chapter 21, <i>Submitting and Committing</i></a> for information on how to submit
1.1 dsieger 2448: such a binary package.</p>
2449: </div>
2450: <div class="sect1" lang="en">
2451: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2452: <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
1.10 hubertf 2453: <p>See <a class="xref" href="#build.helpful-targets" title="17.17. Other helpful targets">Section 17.17, “Other helpful targets”</a>.</p>
1.6 rillig 2454: </div>
2455: </div>
2456: <div class="chapter" lang="en">
2457: <div class="titlepage"><div><div><h2 class="title">
2458: <a name="bulk"></a>Chapter 7. Creating binary packages for everything in pkgsrc (bulk
2459: builds)</h2></div></div></div>
2460: <div class="toc">
2461: <p><b>Table of Contents</b></p>
2462: <dl>
2463: <dt><span class="sect1"><a href="#bulk.pre">7.1. Think first, build later</a></span></dt>
2464: <dt><span class="sect1"><a href="#bulk.req">7.2. Requirements of a bulk build</a></span></dt>
2465: <dt><span class="sect1"><a href="#bulk.old">7.3. Running an old-style bulk build</a></span></dt>
2466: <dd><dl>
2467: <dt><span class="sect2"><a href="#binary.configuration">7.3.1. Configuration</a></span></dt>
2468: <dt><span class="sect2"><a href="#other-environmental-considerations">7.3.2. Other environmental considerations</a></span></dt>
2469: <dt><span class="sect2"><a href="#operation">7.3.3. Operation</a></span></dt>
2470: <dt><span class="sect2"><a href="#what-it-does">7.3.4. What it does</a></span></dt>
2471: <dt><span class="sect2"><a href="#disk-space-requirements">7.3.5. Disk space requirements</a></span></dt>
2472: <dt><span class="sect2"><a href="#setting-up-a-sandbox">7.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
2473: <dt><span class="sect2"><a href="#building-a-partial-set">7.3.7. Building a partial set of packages</a></span></dt>
2474: <dt><span class="sect2"><a href="#bulk-upload">7.3.8. Uploading results of a bulk build</a></span></dt>
2475: </dl></dd>
2476: <dt><span class="sect1"><a href="#bulk.pbulk">7.4. Running a pbulk-style bulk build</a></span></dt>
2477: <dd><dl><dt><span class="sect2"><a href="#bulk.pbulk.conf">7.4.1. Configuration</a></span></dt></dl></dd>
2478: <dt><span class="sect1"><a href="#creating-cdroms">7.5. Creating a multiple CD-ROM packages collection</a></span></dt>
2479: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">7.5.1. Example of cdpack</a></span></dt></dl></dd>
2480: </dl>
2481: </div>
2482: <p>When you have multiple machines that should run the same packages,
2483: it is wasted time if they all build their packages themselves from
2484: source. There are two ways of getting a set of binary packages: The old
2485: bulk build system, or the new (as of 2007) parallel bulk build (pbulk)
2486: system. This chapter describes how to set them up so that the packages
2487: are most likely to be usable later.</p>
2488: <div class="sect1" lang="en">
2489: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2490: <a name="bulk.pre"></a>7.1. Think first, build later</h2></div></div></div>
2491: <p>Since a bulk build takes several days or even weeks to finish, you
2492: should think about the setup before you start everything. Pay attention
2493: to at least the following points:</p>
2494: <div class="itemizedlist"><ul type="disc">
2495: <li>
2496: <p>If you want to upload the binary packages to
2497: ftp.NetBSD.org, make sure the setup complies to the requirements for binary
2498: packages:</p>
2499: <div class="itemizedlist"><ul type="circle">
2500: <li><p>To end up on ftp.NetBSD.org, the packages must be built
2501: by a NetBSD developer on a trusted machine (that is, where you and only
2502: you have root access).</p></li>
2503: <li><p>Packages on ftp.NetBSD.org should only be created from
2504: the stable branches (like 2007Q1), so that users browsing the available
2505: collections can see at a glance how old the packages
2506: are.</p></li>
2507: <li><p>The packages must be built as root, since some packages
2508: require set-uid binaries at runtime, and creating those packages as
2509: unprivileged user doesn't work well at the moment.</p></li>
2510: </ul></div>
2511: </li>
2512: <li><p>Make sure that the bulk build cannot break anything in
2513: your system. Most bulk builds run as root, so they should be run at least
2514: in a chroot environment or something even more restrictive, depending on
2515: what the operating system provides. There have been numerous cases where
2516: certain packages tried to install files outside the
2517: <code class="filename">LOCALBASE</code> or wanted to edit some files in
2518: <code class="filename">/etc</code>. Furthermore, the bulk builds install and
2519: deinstall packages in <code class="filename">/usr/pkg</code> (or whatever
2520: <code class="filename">LOCALBASE</code> is) during their operation, so be sure
2521: that you don't need any package during the build.</p></li>
2522: </ul></div>
2523: </div>
2524: <div class="sect1" lang="en">
2525: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2526: <a name="bulk.req"></a>7.2. Requirements of a bulk build</h2></div></div></div>
2527: <p>A complete bulk build requires lots of disk space. Some of the
2528: disk space can be read-only, some other must be writable. Some can be on
2529: remote filesystems (such as NFS) and some should be local. Some can be
2530: temporary filesystems, others must survive a sudden reboot.</p>
2531: <div class="itemizedlist"><ul type="disc">
2532: <li><p>10 GB for the distfiles (read-write, remote, temporary)</p></li>
2533: <li><p>10 GB for the binary packages (read-write, remote, permanent)</p></li>
2534: <li><p>400 MB for the pkgsrc tree (read-only, remote, permanent)</p></li>
2535: <li><p>5 GB for <code class="filename">LOCALBASE</code> (read-write, local, temporary for pbulk, permanent for old-bulk)</p></li>
2536: <li><p>5 GB for the log files (read-write, remote, permanent)</p></li>
2537: <li><p>5 GB for temporary files (read-write, local, temporary)</p></li>
2538: </ul></div>
1.1 dsieger 2539: </div>
2540: <div class="sect1" lang="en">
2541: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 2542: <a name="bulk.old"></a>7.3. Running an old-style bulk build</h2></div></div></div>
2543: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
2544: <h3 class="title">Warning</h3>
2545: <p>The rest of this section is rather old. Don't rely on it
2546: too much.</p>
2547: </div>
1.1 dsieger 2548: <div class="sect2" lang="en">
2549: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 2550: <a name="binary.configuration"></a>7.3.1. Configuration</h3></div></div></div>
1.1 dsieger 2551: <div class="sect3" lang="en">
2552: <div class="titlepage"><div><div><h4 class="title">
1.6 rillig 2553: <a name="binary.bulk.build.conf"></a>7.3.1.1. <code class="filename">build.conf</code>
1.1 dsieger 2554: </h4></div></div></div>
2555: <p>The <code class="filename">build.conf</code> file is the main
2556: configuration file for bulk builds. You can configure how your
2557: copy of pkgsrc is kept up to date, how the distfiles are
2558: downloaded, how the packages are built and how the report is
2559: generated. You can find an annotated example file in
2560: <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
2561: it, copy <code class="filename">build.conf-example</code> to
2562: <code class="filename">build.conf</code> and edit it, following the
2563: comments in that file.</p>
2564: </div>
2565: <div class="sect3" lang="en">
2566: <div class="titlepage"><div><div><h4 class="title">
1.10 hubertf 2567: <a name="binary.mk.conf"></a>7.3.1.2. <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>
1.4 rillig 2568: </h4></div></div></div>
1.10 hubertf 2569: <p>You may want to set variables in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.
1.1 dsieger 2570: Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
2571: details of the default settings. You will want to ensure that
2572: <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
2573: As used in this example, <code class="varname">_ACCEPTABLE=yes</code>
1.4 rillig 2574: completely bypasses the license check.</p>
1.1 dsieger 2575: <pre class="programlisting">
2576: PACKAGES?= ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
2577: WRKOBJDIR?= /usr/tmp/pkgsrc # build here instead of in pkgsrc
2578: BSDSRCDIR= /usr/src
2579: BSDXSRCDIR= /usr/xsrc # for x11/xservers
2580: OBJHOSTNAME?= yes # use work.`hostname`
2581: FAILOVER_FETCH= yes # insist on the correct checksum
2582: PKG_DEVELOPER?= yes
2583: _ACCEPTABLE= yes
2584: </pre>
2585: <p>Some options that are especially useful for bulk builds
2586: can be found at the top lines of the file
2587: <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
2588: options of these are briefly described here.</p>
2589: <div class="itemizedlist"><ul type="disc">
2590: <li><p>If you are on a slow machine, you may want to
2591: set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
2592: “<span class="quote">no</span>”.</p></li>
2593: <li><p>If you are doing bulk builds from a read-only
2594: copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
2595: to the directory where all log files are created. Otherwise the
2596: log files are created in the pkgsrc directory.</p></li>
2597: <li><p>Another important variable is
2598: <code class="varname">BULK_PREREQ</code>, which is a list of packages that
2599: should be always available while building other
2600: packages.</p></li>
2601: </ul></div>
2602: <p>Some other options are scattered in the pkgsrc
2603: infrastructure:</p>
2604: <div class="itemizedlist"><ul type="disc">
2605: <li><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
2606: should be set to <code class="literal">yes</code>. The purpose of the bulk
2607: builds is creating binary packages, no matter if they are
2608: vulnerable or not. When uploading the packages to a public
2609: server, the vulnerable packages will be put into a directory of
2610: their own. Leaving this variable unset would prevent the bulk
2611: build system from even trying to build them, so possible
2612: building errors would not show up.</p></li>
2613: <li><p><code class="varname">CHECK_FILES</code>
2614: (<code class="filename">pkgsrc/mk/check/check-files.mk</code>) can be set to
2615: “<span class="quote">yes</span>” to check that the installed set of files
2616: matches the <code class="filename">PLIST</code>.</p></li>
2617: <li><p><code class="varname">CHECK_INTERPRETER</code>
2618: (<code class="filename">pkgsrc/mk/check/check-interpreter.mk</code>) can be set to
2619: “<span class="quote">yes</span>” to check that the installed
2620: “<span class="quote">#!</span>”-scripts will find their
2621: interpreter.</p></li>
2622: <li><p><code class="varname">PKGSRC_RUN_TEST</code> can be
2623: set to “<span class="quote"><code class="literal">yes</code></span>” to run each
2624: package's self-test before installing it. Note that some
2625: packages make heavy use of “<span class="quote">good</span>” random
2626: numbers, so you need to assure that the machine on which you
2627: are doing the bulk builds is not completely idle. Otherwise
2628: some test programs will seem to hang, while they are just
2629: waiting for new random data to be
2630: available.</p></li>
2631: </ul></div>
2632: </div>
2633: <div class="sect3" lang="en">
2634: <div class="titlepage"><div><div><h4 class="title">
1.6 rillig 2635: <a name="pre-build.local"></a>7.3.1.3. <code class="filename">pre-build.local</code>
1.1 dsieger 2636: </h4></div></div></div>
2637: <p>It is possible to configure the bulk build to perform
2638: certain site-specific tasks at the end of the pre-build
2639: stage. If the file
2640: <code class="filename">pre-build.local</code> exists in
2641: <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
1.10 hubertf 2642: (as a <a class="citerefentry" 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
1.1 dsieger 2643: stage. An example use of
2644: <code class="filename">pre-build.local</code> is to have the line:</p>
2645: <pre class="screen">echo "I do not have enough disk space to build this pig." \
2646: > misc/openoffice/$BROKENF</pre>
2647: <p>to prevent the system from trying to build a particular package
2648: which requires nearly 3 GB of disk space.</p>
2649: </div>
2650: </div>
2651: <div class="sect2" lang="en">
2652: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 2653: <a name="other-environmental-considerations"></a>7.3.2. Other environmental considerations</h3></div></div></div>
1.1 dsieger 2654: <p>As <code class="filename">/usr/pkg</code> will be completely
2655: deleted at the start of bulk builds, make sure your login
2656: shell is placed somewhere else. Either drop it into
2657: <code class="filename">/usr/local/bin</code> (and adjust your login
2658: shell in the passwd file), or (re-)install it via
1.10 hubertf 2659: <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> from <code class="filename">/etc/rc.local</code>, so
1.1 dsieger 2660: you can login after a reboot (remember that your current
2661: process won't die if the package is removed, you just can't
2662: start any new instances of the shell any more). Also, if you
2663: use NetBSD earlier than 1.5, or you still want to use the pkgsrc
2664: version of ssh for some reason, be sure to install ssh before
2665: starting it from <code class="filename">rc.local</code>:</p>
2666: <pre class="programlisting">
2667: (cd /usr/pkgsrc/security/ssh && make bulk-install)
2668: if [ -f /usr/pkg/etc/rc.d/sshd ]; then
2669: /usr/pkg/etc/rc.d/sshd
2670: fi
2671: </pre>
2672: <p>Not doing so will result in you being not able to log in
2673: via ssh after the bulk build is finished or if the machine
2674: gets rebooted or crashes. You have been warned! :)</p>
2675: </div>
2676: <div class="sect2" lang="en">
2677: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 2678: <a name="operation"></a>7.3.3. Operation</h3></div></div></div>
1.1 dsieger 2679: <p>Make sure you don't need any of the packages still
2680: installed.</p>
2681: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
2682: <h3 class="title">Warning</h3>
2683: <p>During the bulk build, <span class="emphasis"><em>all packages, their
2684: configuration files and some more files from
2685: <code class="filename">/var</code>, <code class="filename">/home</code> and
2686: possibly other locations will be removed! So don't run a bulk
2687: build with privileges that might harm your
2688: system.</em></span></p>
2689: </div>
2690: <p>Be sure to remove all other things that might
2691: interfere with builds, like some libs installed in
2692: <code class="filename">/usr/local</code>, etc. then become root and type:</p>
2693: <pre class="screen">
2694: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2695: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong>
2696: </pre>
2697: <p>If for some reason your last build didn't complete (power
2698: failure, system panic, ...), you can continue it by
2699: running:</p>
2700: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
2701: <p>At the end of the bulk build, you will get a summary via mail,
2702: and find build logs in the directory specified by
2703: <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
2704: file.</p>
2705: </div>
2706: <div class="sect2" lang="en">
2707: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 2708: <a name="what-it-does"></a>7.3.4. What it does</h3></div></div></div>
1.1 dsieger 2709: <p>The bulk builds consist of three steps:</p>
2710: <div class="variablelist"><dl>
2711: <dt><span class="term">1. pre-build</span></dt>
2712: <dd><p>The script updates your pkgsrc tree via (anon)cvs, then
2713: cleans out any broken distfiles, and removes all
2714: packages installed.</p></dd>
2715: <dt><span class="term">2. the bulk build</span></dt>
2716: <dd><p>This is basically “<span class="quote">make bulk-package</span>” with
2717: an optimised order in which packages will be
2718: built. Packages that don't require other packages will
2719: be built first, and packages with many dependencies will
2720: be built later.</p></dd>
2721: <dt><span class="term">3. post-build</span></dt>
2722: <dd><p>Generates a report that's placed in the directory
2723: specified in the <code class="filename">build.conf</code> file
2724: named <code class="filename">broken.html</code>, a short version
2725: of that report will also be mailed to the build's
2726: admin.</p></dd>
2727: </dl></div>
2728: <p>During the build, a list of broken packages will be compiled
2729: in <code class="filename">/usr/pkgsrc/.broken</code> (or
2730: <code class="filename">.../.broken.${MACHINE}</code> if
2731: <code class="varname">OBJMACHINE</code> is set), individual build logs
2732: of broken builds can be found in the package's
2733: directory. These files are used by the bulk-targets to mark
2734: broken builds to not waste time trying to rebuild them, and
2735: they can be used to debug these broken package builds
2736: later.</p>
2737: </div>
2738: <div class="sect2" lang="en">
2739: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 2740: <a name="disk-space-requirements"></a>7.3.5. Disk space requirements</h3></div></div></div>
1.1 dsieger 2741: <p>Currently, roughly the following requirements are valid for
2742: NetBSD 2.0/i386:</p>
2743: <div class="itemizedlist"><ul type="disc">
2744: <li><p>10 GB - distfiles (NFS ok)</p></li>
2745: <li><p>8 GB - full set of all binaries (NFS ok)</p></li>
2746: <li><p>5 GB - temp space for compiling (local disk recommended)</p></li>
2747: </ul></div>
2748: <p>Note that all pkgs will be de-installed as soon as they are
2749: turned into a binary package, and that sources are removed,
2750: so there is no excessively huge demand to disk
2751: space. Afterwards, if the package is needed again, it will
1.10 hubertf 2752: be installed via <a class="citerefentry" 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
1.1 dsieger 2753: there are no cycles wasted by recompiling.</p>
2754: </div>
2755: <div class="sect2" lang="en">
2756: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 2757: <a name="setting-up-a-sandbox"></a>7.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
1.1 dsieger 2758: <p>If you don't want all the packages nuked from a machine
2759: (rendering it useless for anything but pkg compiling), there
2760: is the possibility of doing the package bulk build inside a
2761: chroot environment.</p>
2762: <p>The first step is to set up a chroot sandbox,
2763: e.g. <code class="filename">/usr/sandbox</code>. This can be done by
2764: using null mounts, or manually.</p>
2765: <p>There is a shell script called
2766: <code class="filename">pkgsrc/mk/bulk/mksandbox</code> which will set
2767: up the sandbox environment using null mounts. It will also
2768: create a script called <code class="filename">sandbox</code> in the
2769: root of the sandbox environment, which will allow the null
1.10 hubertf 2770: mounts to be activated using the <span class="command"><strong>sandbox
1.1 dsieger 2771: mount</strong></span> command and deactivated using the
1.10 hubertf 2772: <span class="command"><strong>sandbox umount</strong></span> command.</p>
1.1 dsieger 2773: <p>To set up a sandbox environment by hand, after extracting all
1.10 hubertf 2774: the sets from a NetBSD installation or doing a <span class="command"><strong>make
1.1 dsieger 2775: distribution DESTDIR=/usr/sandbox</strong></span> in
2776: <code class="filename">/usr/src/etc</code>, be sure the following items
2777: are present and properly configured:</p>
2778: <div class="procedure"><ol type="1">
2779: <li>
2780: <p>Kernel</p>
2781: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
2782: </li>
2783: <li>
2784: <p><code class="filename">/dev/*</code></p>
2785: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
2786: </li>
2787: <li>
2788: <p><code class="filename">/etc/resolv.conf</code> (for <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/smtpd/README.html" target="_top"><code class="filename">security/smtpd</code></a> and mail):</p>
2789: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
2790: </li>
2791: <li>
2792: <p>Working(!) mail config (hostname, sendmail.cf):</p>
2793: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
2794: </li>
2795: <li>
2796: <p><code class="filename">/etc/localtime</code> (for <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/smtpd/README.html" target="_top"><code class="filename">security/smtpd</code></a>):</p>
2797: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
2798: </li>
2799: <li>
2800: <p><code class="filename">/usr/src</code> (system sources,
1.14 ! jmcneill 2801: e. g. for <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/sysutils/aperture/README.html" target="_top"><code class="filename">sysutils/aperture</code></a>):</p>
1.1 dsieger 2802: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
2803: <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
2804: </li>
2805: <li>
2806: <p>Create <code class="filename">/var/db/pkg</code> (not part of default install):</p>
2807: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong></pre>
2808: </li>
2809: <li>
2810: <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
2811: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
2812: </li>
2813: <li>
2814: <p>Checkout pkgsrc via cvs into
2815: <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
2816: <pre class="screen">
2817: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
2818: <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong>
2819: </pre>
2820: <p>Do not mount/link this to the copy of your pkgsrc tree
2821: you do development in, as this will likely cause problems!</p>
2822: </li>
2823: <li><p>Make
2824: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
2825: <code class="filename">.../distfiles</code> point somewhere
2826: appropriate. NFS- and/or nullfs-mounts may come in handy!</p></li>
1.10 hubertf 2827: <li><p>Edit <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>, see <a class="xref" href="#binary.mk.conf" title="7.3.1.2. mk.conf">Section 7.3.1.2, “<code class="filename">mk.conf</code>”</a>.</p></li>
1.1 dsieger 2828: <li><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
2829: </ol></div>
2830: <p>When the chroot sandbox is set up, you can start
2831: the build with the following steps:</p>
2832: <pre class="screen">
2833: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2834: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong>
2835: </pre>
2836: <p>This will just jump inside the sandbox and start building. At
2837: the end of the build, mail will be sent with the results of
2838: the build. Created binary pkgs will be in
2839: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
2840: (wherever that points/mounts to/from).</p>
2841: </div>
2842: <div class="sect2" lang="en">
2843: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 2844: <a name="building-a-partial-set"></a>7.3.7. Building a partial set of packages</h3></div></div></div>
1.1 dsieger 2845: <p>In addition to building a complete set of all packages in
2846: pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
2847: may be used to build a subset of the packages contained in
2848: pkgsrc. By setting <code class="varname">SPECIFIC_PKGS</code>
1.10 hubertf 2849: in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>, the variables</p>
1.1 dsieger 2850: <div class="itemizedlist"><ul type="disc">
2851: <li><p>SITE_SPECIFIC_PKGS</p></li>
2852: <li><p>HOST_SPECIFIC_PKGS</p></li>
2853: <li><p>GROUP_SPECIFIC_PKGS</p></li>
2854: <li><p>USER_SPECIFIC_PKGS</p></li>
2855: </ul></div>
2856: <p>will define the set of packages which should be built.
2857: The bulk build code will also include any packages which are
2858: needed as dependencies for the explicitly listed packages.</p>
2859: <p>One use of this is to do a bulk build with
2860: <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
2861: periodically to have a complete set of the binary packages
2862: needed for your site available without the overhead of
2863: building extra packages that are not needed.</p>
2864: </div>
2865: <div class="sect2" lang="en">
2866: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 2867: <a name="bulk-upload"></a>7.3.8. Uploading results of a bulk build</h3></div></div></div>
1.1 dsieger 2868: <p>This section describes how pkgsrc developers can upload binary
2869: pkgs built by bulk builds to ftp.NetBSD.org.</p>
2870: <p>If you would like to automatically create checksum files for the
2871: binary packages you intend to upload, remember to set
2872: <code class="varname">MKSUMS=yes</code> in your
2873: <code class="filename">mk/bulk/build.conf</code>.</p>
2874: <p>If you would like to PGP sign the checksum files (highly
2875: recommended!), remember to set
2876: <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
2877: <code class="filename">mk/bulk/build.conf</code>. This will prompt you for
2878: your GPG password to sign the files before uploading everything.</p>
2879: <p>Then, make sure that you have <code class="varname">RSYNC_DST</code>
2880: set properly in your <code class="filename">mk/bulk/build.conf</code>
2881: file, i.e. adjust it to something like one of the following:</p>
2882: <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/NetBSD/packages/packages-200xQy/NetBSD-a.b.c/arch/upload </pre>
2883: <p>Please use appropriate values for "packages-200xQy",
2884: "NetBSD-a.b.c" and "arch" here. If your login on ftp.NetBSD.org
2885: is different from your local login, write your login directly
2886: into the variable, e.g. my local account is "feyrer", but for my
2887: login "hubertf", I use:</p>
2888: <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/packages-200xQy/NetBSD-a.b.c/arch/upload</pre>
2889: <p>A separate <code class="filename">upload</code> directory is used
2890: here to allow "closing" the directory during upload. To do
2891: so, run the following command on ftp.NetBSD.org next:</p>
2892: <pre class="screen">nbftp% <strong class="userinput"><code>mkdir -p -m 750 /pub/NetBSD/packages/packages-200xQy/NetBSD-a.b.c/arch/upload</code></strong></pre>
2893: <p>Please note that <code class="filename">/pub/NetBSD/packages</code> is
2894: only appropriate for packages for the NetBSD operating
2895: system. Binary packages for other operating systems should go
2896: into <code class="filename">/pub/pkgsrc</code>.</p>
2897: <p>Before uploading the binary pkgs, ssh authentication needs
2898: to be set up. This example shows how to set up temporary keys
2899: for the root account <span class="emphasis"><em>inside the sandbox</em></span>
2900: (assuming that no keys should be present there usually):</p>
2901: <pre class="screen">
2902: <code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
2903: chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
2904: chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t dsa</code></strong>
2905: chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong>
2906: </pre>
2907: <p>Now take the output of <code class="filename">id-dsa.pub</code> and
2908: append it to your <code class="filename">~/.ssh/authorized_keys</code>
2909: file on ftp.NetBSD.org. You can remove the key after the
2910: upload is done!</p>
2911: <p>Next, test if your ssh connection really works:</p>
2912: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
2913: <p>Use "-l yourNetBSDlogin" here as appropriate!</p>
2914: <p>Now after all this works, you can exit the sandbox and start
2915: the upload:</p>
2916: <pre class="screen">
2917: chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
2918: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2919: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong>
2920: </pre>
1.10 hubertf 2921: <p>The upload process may take quite some time. Use <a class="citerefentry" 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
2922: <a class="citerefentry" 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
1.1 dsieger 2923: upload. The upload script will take care of not uploading
2924: restricted packages and putting vulnerable packages into the
2925: <code class="filename">vulnerable</code> subdirectory.</p>
2926: <p>After the upload has ended, first thing is to revoke ssh access:</p>
2927: <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
2928: Gdd:x! </pre>
2929: <p>Use whatever is needed to remove the key you've entered
2930: before! Last, move the uploaded packages out of the
2931: <code class="filename">upload</code> directory to have them accessible
2932: to everyone:</p>
2933: <pre class="screen">
2934: nbftp% <strong class="userinput"><code>cd /pub/NetBSD/packages/packages-200xQy/NetBSD-a.b.c/arch</code></strong>
2935: nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
2936: nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
2937: nbftp% <strong class="userinput"><code>chmod 755 .</code></strong>
2938: </pre>
2939: </div>
2940: </div>
2941: <div class="sect1" lang="en">
2942: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 2943: <a name="bulk.pbulk"></a>7.4. Running a pbulk-style bulk build</h2></div></div></div>
2944: <div class="sect2" lang="en">
2945: <div class="titlepage"><div><div><h3 class="title">
2946: <a name="bulk.pbulk.conf"></a>7.4.1. Configuration</h3></div></div></div>
1.14 ! jmcneill 2947: <p>TODO; see pkgsrc/doc/HOWTO-pbulk for more information.</p>
1.6 rillig 2948: </div>
2949: </div>
2950: <div class="sect1" lang="en">
2951: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2952: <a name="creating-cdroms"></a>7.5. Creating a multiple CD-ROM packages collection</h2></div></div></div>
1.1 dsieger 2953: <p>After your pkgsrc bulk-build has completed, you may wish to
2954: create a CD-ROM set of the resulting binary packages to assist
2955: in installing packages on other machines. The
2956: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/cdpack/README.html" target="_top"><code class="filename">pkgtools/cdpack</code></a> package provides
2957: a simple tool for creating the ISO 9660 images.
1.10 hubertf 2958: <span class="command"><strong>cdpack</strong></span> arranges the packages on the CD-ROMs in a
1.1 dsieger 2959: way that keeps all the dependencies for a given package on the same
2960: CD as that package.</p>
2961: <div class="sect2" lang="en">
2962: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 2963: <a name="cdpack-example"></a>7.5.1. Example of cdpack</h3></div></div></div>
1.1 dsieger 2964: <p>Complete documentation for cdpack is found in the cdpack(1)
2965: man page. The following short example assumes that the binary
2966: packages are left in
2967: <code class="filename">/usr/pkgsrc/packages/All</code> and that
2968: sufficient disk space exists in <code class="filename">/u2</code> to
2969: hold the ISO 9660 images.</p>
2970: <pre class="screen">
2971: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
2972: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
2973: <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong>
2974: </pre>
2975: <p>If you wish to include a common set of files
2976: (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
2977: etc.) on each CD in the collection, then you need to create a
2978: directory which contains these files. e.g.</p>
2979: <pre class="screen">
2980: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
2981: <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" > /tmp/common/README</code></strong>
2982: <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" > /tmp/common/COPYING</code></strong>
2983: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
2984: <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" > /tmp/common/bin/myscript</code></strong>
2985: <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" >> /tmp/common/bin/myscript</code></strong>
2986: <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong>
2987: </pre>
2988: <p>Now create the images:</p>
2989: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images</code></strong></pre>
2990: <p>Each image will contain <code class="filename">README</code>,
2991: <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
2992: in their root directories.</p>
2993: </div>
2994: </div>
2995: </div>
2996: <div class="chapter" lang="en">
2997: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 2998: <a name="files"></a>Chapter 8. Directory layout of the installed files</h2></div></div></div>
1.1 dsieger 2999: <div class="toc">
3000: <p><b>Table of Contents</b></p>
3001: <dl>
1.6 rillig 3002: <dt><span class="sect1"><a href="#files.localbase">8.1. File system layout in <code class="literal">${LOCALBASE}</code></a></span></dt>
3003: <dt><span class="sect1"><a href="#files.varbase">8.2. File system layout in <code class="literal">${VARBASE}</code></a></span></dt>
1.1 dsieger 3004: </dl>
3005: </div>
3006: <p>The files that are installed by pkgsrc are organized in a way that
3007: is similar to what you find in the <code class="filename">/usr</code> directory
3008: of the base system. But some details are different. This is because
3009: pkgsrc initially came from FreeBSD and had adopted its file system
3010: hierarchy. Later it was largely influenced by NetBSD. But no matter
3011: which operating system you are using pkgsrc with, you can expect the
3012: same layout for pkgsrc.</p>
3013: <p>There are mainly four root directories for pkgsrc, which are all
3014: configurable in the <code class="filename">bootstrap/bootstrap</code> script.
3015: When pkgsrc has been installed as root, the default locations
3016: are:</p>
3017: <pre class="programlisting">
3018: LOCALBASE= /usr/pkg
3019: PKG_SYSCONFBASE= /usr/pkg/etc
3020: VARBASE= /var
3021: PKG_DBDIR= /var/db/pkg
3022: </pre>
3023: <p>In unprivileged mode (when pkgsrc has been installed as any other
3024: user), the default locations are:</p>
3025: <pre class="programlisting">
3026: LOCALBASE= ${HOME}/pkg
3027: PKG_SYSCONFBASE= ${HOME}/pkg/etc
3028: VARBASE= ${HOME}/pkg/var
3029: PKG_DBDIR= ${HOME}/pkg/var/db/pkg
3030: </pre>
3031: <p>What these four directories are for, and what they look like is
3032: explained below.</p>
3033: <div class="itemizedlist"><ul type="disc">
3034: <li><p><code class="varname">LOCALBASE</code> corresponds to the
3035: <code class="filename">/usr</code> directory in the base system. It is the
3036: “<span class="quote">main</span>” directory where the files are installed and contains
3037: the well-known subdirectories like <code class="filename">bin</code>,
3038: <code class="filename">include</code>, <code class="filename">lib</code>,
3039: <code class="filename">share</code> and
3040: <code class="filename">sbin</code>.</p></li>
3041: <li><p><code class="varname">VARBASE</code> corresponds to
3042: <code class="filename">/var</code> in the base system. Some programs (especially
3043: games, network daemons) need write access to it during normal
3044: operation.</p></li>
3045: <li><p><code class="varname">PKG_SYSCONFDIR</code> corresponds to
3046: <code class="filename">/etc</code> in the base system. It contains configuration
1.10 hubertf 3047: files of the packages, as well as pkgsrc's <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>
1.1 dsieger 3048: itself.</p></li>
3049: </ul></div>
3050: <div class="sect1" lang="en">
3051: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3052: <a name="files.localbase"></a>8.1. File system layout in <code class="literal">${LOCALBASE}</code>
1.1 dsieger 3053: </h2></div></div></div>
3054: <p>The following directories exist in a typical pkgsrc installation
3055: in <code class="filename">${LOCALBASE}</code>.</p>
3056: <div class="variablelist"><dl>
3057: <dt><span class="term"><code class="filename">bin</code></span></dt>
3058: <dd><p>Contains executable programs that are intended to be
3059: directly used by the end user.</p></dd>
3060: <dt><span class="term"><code class="filename">emul</code></span></dt>
3061: <dd><p>Contains files for the emulation layers of various other
3062: operating systems, especially for
3063: NetBSD.</p></dd>
3064: <dt><span class="term"><code class="filename">etc</code> (the usual location of
3065: <code class="filename">${PKG_SYSCONFDIR}</code>)</span></dt>
3066: <dd><p>Contains
3067: the configuration files.</p></dd>
3068: <dt><span class="term"><code class="filename">include</code></span></dt>
3069: <dd><p>Contains headers for the C and C++ programming
3070: languages.</p></dd>
3071: <dt><span class="term"><code class="filename">info</code></span></dt>
3072: <dd><p>Contains GNU info files of various
3073: packages.</p></dd>
3074: <dt><span class="term"><code class="filename">lib</code></span></dt>
3075: <dd><p>Contains shared and static
3076: libraries.</p></dd>
3077: <dt><span class="term"><code class="filename">libdata</code></span></dt>
3078: <dd><p>Contains data files that don't change after
3079: installation. Other data files belong into
3080: <code class="filename">${VARBASE}</code>.</p></dd>
3081: <dt><span class="term"><code class="filename">libexec</code></span></dt>
3082: <dd><p>Contains programs that are not intended to be used by
3083: end users, such as helper programs or network
3084: daemons.</p></dd>
3085: <dt><span class="term"><code class="filename">libexec/cgi-bin</code></span></dt>
3086: <dd><p>Contains programs that are intended to be executed as
3087: CGI scripts by a web server.</p></dd>
3088: <dt><span class="term"><code class="filename">man</code> (the usual value of
3089: <code class="filename">${PKGMANDIR}</code>)</span></dt>
3090: <dd><p>Contains brief
3091: documentation in form of manual pages.</p></dd>
3092: <dt><span class="term"><code class="filename">sbin</code></span></dt>
3093: <dd><p>Contains programs that are intended to be used only by
3094: the super-user.</p></dd>
3095: <dt><span class="term"><code class="filename">share</code></span></dt>
3096: <dd><p>Contains platform-independent data files that don't
3097: change after installation.</p></dd>
3098: <dt><span class="term"><code class="filename">share/doc</code></span></dt>
3099: <dd><p>Contains documentation files provided by the
3100: packages.</p></dd>
3101: <dt><span class="term"><code class="filename">share/examples</code></span></dt>
3102: <dd><p>Contains example files provided by the packages. Among
3103: others, the original configuration files are saved here and copied to
3104: <code class="filename">${PKG_SYSCONFDIR}</code> during
3105: installation.</p></dd>
3106: <dt><span class="term"><code class="filename">share/examples/rc.d</code></span></dt>
3107: <dd><p>Contains the original files for rc.d
3108: scripts.</p></dd>
3109: <dt><span class="term"><code class="filename">var</code> (the usual location of
3110: <code class="filename">${VARBASE}</code>)</span></dt>
3111: <dd><p>Contains files
3112: that may be modified after
3113: installation.</p></dd>
3114: </dl></div>
3115: </div>
3116: <div class="sect1" lang="en">
3117: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3118: <a name="files.varbase"></a>8.2. File system layout in <code class="literal">${VARBASE}</code>
1.1 dsieger 3119: </h2></div></div></div>
3120: <div class="variablelist"><dl>
3121: <dt><span class="term"><code class="filename">db/pkg</code> (the usual location of
3122: <code class="filename">${PKG_DBDIR}</code>)</span></dt>
3123: <dd><p>Contains
3124: information about the currently installed
3125: packages.</p></dd>
3126: <dt><span class="term"><code class="filename">games</code></span></dt>
3127: <dd><p>Contains highscore
3128: files.</p></dd>
3129: <dt><span class="term"><code class="filename">log</code></span></dt>
3130: <dd><p>Contains log files.</p></dd>
3131: <dt><span class="term"><code class="filename">run</code></span></dt>
3132: <dd><p>Contains informational files about daemons that are
3133: currently running.</p></dd>
3134: </dl></div>
3135: </div>
3136: </div>
3137: <div class="chapter" lang="en">
3138: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 3139: <a name="faq"></a>Chapter 9. Frequently Asked Questions</h2></div></div></div>
1.1 dsieger 3140: <div class="toc">
3141: <p><b>Table of Contents</b></p>
3142: <dl>
1.6 rillig 3143: <dt><span class="sect1"><a href="#mailing-list-pointers">9.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
3144: <dt><span class="sect1"><a href="#pkgviews-docs">9.2. Where's the pkgviews documentation?</a></span></dt>
3145: <dt><span class="sect1"><a href="#faq-pkgtools">9.3. Utilities for package management (pkgtools)</a></span></dt>
3146: <dt><span class="sect1"><a href="#non-root-pkgsrc">9.4. How to use pkgsrc as non-root</a></span></dt>
3147: <dt><span class="sect1"><a href="#resume-transfers">9.5. How to resume transfers when fetching distfiles?</a></span></dt>
3148: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">9.6. How can I install/use modular X.org from pkgsrc?</a></span></dt>
3149: <dt><span class="sect1"><a href="#fetch-behind-firewall">9.7. How to fetch files from behind a firewall</a></span></dt>
1.10 hubertf 3150: <dt><span class="sect1"><a href="#passive-ftp">9.8. How do I tell <span class="command"><strong>make fetch</strong></span> to do passive FTP?</a></span></dt>
1.6 rillig 3151: <dt><span class="sect1"><a href="#fetching-all-distfiles">9.9. How to fetch all distfiles at once</a></span></dt>
3152: <dt><span class="sect1"><a href="#tmac.andoc-missing">9.10. What does “<span class="quote">Don't know how to make
1.1 dsieger 3153: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
1.6 rillig 3154: <dt><span class="sect1"><a href="#bsd.own.mk-missing">9.11. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</a></span></dt>
3155: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">9.12. Using 'sudo' with pkgsrc</a></span></dt>
3156: <dt><span class="sect1"><a href="#faq.conf">9.13. How do I change the location of configuration files?</a></span></dt>
3157: <dt><span class="sect1"><a href="#audit-packages">9.14. Automated security checks</a></span></dt>
3158: <dt><span class="sect1"><a href="#ufaq-cflags">9.15. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
3159: <dt><span class="sect1"><a href="#ufaq-fail">9.16. A package does not build. What shall I do?</a></span></dt>
3160: <dt><span class="sect1"><a href="#faq.rcs-conflicts">9.17. What does “<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>” mean?</a></span></dt>
1.1 dsieger 3161: </dl>
3162: </div>
3163: <p>This section contains hints, tips & tricks on special things in
3164: pkgsrc that we didn't find a better place for in the previous chapters, and
3165: it contains items for both pkgsrc users and developers.</p>
3166: <div class="sect1" lang="en">
3167: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3168: <a name="mailing-list-pointers"></a>9.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
1.1 dsieger 3169: <p>The following mailing lists may be of interest to pkgsrc users:</p>
3170: <div class="itemizedlist"><ul type="disc">
1.10 hubertf 3171: <li><p><a class="ulink" href="http://www.NetBSD.org/mailinglists/index.html#pkgsrc-users" target="_top">pkgsrc-users</a>:
1.1 dsieger 3172: This is a general purpose list for most issues regarding
3173: pkgsrc, regardless of platform, e.g. soliciting user help
3174: for pkgsrc configuration, unexpected build failures, using
3175: particular packages, upgrading pkgsrc installations,
3176: questions regarding the pkgsrc release branches, etc. General announcements or
3177: proposals for changes that impact the pkgsrc user community,
3178: e.g. major infrastructure changes, new features, package
3179: removals, etc., may also be posted.</p></li>
1.10 hubertf 3180: <li><p><a class="ulink" href="http://www.NetBSD.org/mailinglists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
1.1 dsieger 3181: A list where the results of pkgsrc bulk builds are sent and
3182: discussed.</p></li>
1.10 hubertf 3183: <li><p><a class="ulink" href="http://www.NetBSD.org/mailinglists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
1.1 dsieger 3184: This list is for those who are interested in getting a
3185: commit message for every change committed to pkgsrc. It is
3186: also available in digest form, meaning one daily message
3187: containing all commit messages for changes to the package
3188: source tree in that 24 hour period.</p></li>
3189: </ul></div>
3190: <p>To subscribe, do:</p>
3191: <pre class="programlisting">
3192: <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
3193: </pre>
3194: <p>Archives for all these mailing lists are available from
1.10 hubertf 3195: <a class="ulink" href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
1.1 dsieger 3196: </div>
3197: <div class="sect1" lang="en">
3198: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3199: <a name="pkgviews-docs"></a>9.2. Where's the pkgviews documentation?</h2></div></div></div>
1.1 dsieger 3200: <p>Pkgviews is tightly integrated with buildlink. You can find a
3201: pkgviews User's guide in
3202: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
3203: </div>
3204: <div class="sect1" lang="en">
3205: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3206: <a name="faq-pkgtools"></a>9.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.1 dsieger 3207: <p>The directory <code class="filename">pkgsrc/pkgtools</code> contains
3208: a number of useful utilities for both users and developers of pkgsrc. This
3209: section attempts only to make the reader aware of the utilities and when
3210: they might be useful, and not to duplicate the documentation that comes
3211: with each package.</p>
3212: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
3213: <div class="itemizedlist"><ul type="disc"><li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/x11-links/README.html" target="_top"><code class="filename">pkgtools/x11-links</code></a>:
3214: Symlinks for use by buildlink.</p></li></ul></div>
3215: <p>OS tool augmentation (automatically installed when needed):</p>
3216: <div class="itemizedlist"><ul type="disc">
3217: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/digest/README.html" target="_top"><code class="filename">pkgtools/digest</code></a>:
3218: Calculates various kinds of checksums (including SHA1).</p></li>
3219: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/libnbcompat/README.html" target="_top"><code class="filename">pkgtools/libnbcompat</code></a>:
3220: Compatibility library for pkgsrc tools.</p></li>
3221: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/mtree/README.html" target="_top"><code class="filename">pkgtools/mtree</code></a>: Installed on
3222: non-BSD systems due to lack of native mtree.</p></li>
3223: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a>:
3224: Up-to-date replacement for
3225: <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
3226: systems where pkg_install is not present.</p></li>
3227: </ul></div>
3228: <p>Utilities used by pkgsrc (not automatically installed):</p>
3229: <div class="itemizedlist"><ul type="disc">
3230: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_tarup/README.html" target="_top"><code class="filename">pkgtools/pkg_tarup</code></a>:
3231: Create a binary package from an
1.10 hubertf 3232: already-installed package. Used by <span class="command"><strong>make replace</strong></span> to
1.1 dsieger 3233: save the old package.</p></li>
3234: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/dfdisk/README.html" target="_top"><code class="filename">pkgtools/dfdisk</code></a>:
3235: Adds extra functionality to pkgsrc, allowing it to fetch distfiles
3236: from multiple locations. It currently supports the following
3237: methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
3238: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a>: Put X11
3239: packages someplace else (enabled by default).</p></li>
3240: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/cpuflags/README.html" target="_top"><code class="filename">devel/cpuflags</code></a>: Determine the
3241: best compiler flags to optimise code for your current CPU and
3242: compiler.</p></li>
3243: </ul></div>
3244: <p>Utilities for keeping track of installed packages, being up to date,
3245: etc:</p>
3246: <div class="itemizedlist"><ul type="disc">
3247: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_chk/README.html" target="_top"><code class="filename">pkgtools/pkg_chk</code></a>: Reports on
3248: packages whose installed versions do not match the latest pkgsrc
3249: entries.</p></li>
3250: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdep/README.html" target="_top"><code class="filename">pkgtools/pkgdep</code></a>: Makes
3251: dependency graphs of packages, to aid in choosing a strategy for
3252: updating.</p></li>
3253: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdepgraph/README.html" target="_top"><code class="filename">pkgtools/pkgdepgraph</code></a>: Makes
3254: graphs from the output of <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdep/README.html" target="_top"><code class="filename">pkgtools/pkgdep</code></a> (uses graphviz).</p></li>
3255: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>: The
1.12 weinem 3256: pkglint(1) program checks a pkgsrc entry for errors.</p></li>
3257: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/lintpkgsrc/README.html" target="_top"><code class="filename">pkgtools/lintpkgsrc</code></a>: The lintpkgsrc(1) program
1.1 dsieger 3258: does various checks on the complete pkgsrc system.</p></li>
3259: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgsurvey/README.html" target="_top"><code class="filename">pkgtools/pkgsurvey</code></a>: Report what
3260: packages you have installed.</p></li>
3261: </ul></div>
3262: <p>Utilities for people maintaining or creating individual packages:</p>
3263: <div class="itemizedlist"><ul type="disc">
3264: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a>: Automate
3265: making and maintaining patches for a package (includes pkgdiff,
3266: pkgvi, mkpatches, etc.).</p></li>
3267: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/rpm2pkg/README.html" target="_top"><code class="filename">pkgtools/rpm2pkg</code></a>,
3268: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a>: Aids in
3269: converting to pkgsrc.</p></li>
3270: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/gensolpkg/README.html" target="_top"><code class="filename">pkgtools/gensolpkg</code></a>: Convert
3271: pkgsrc to a Solaris package.</p></li>
3272: </ul></div>
3273: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
3274: utilities)</p>
3275: <div class="itemizedlist"><ul type="disc">
3276: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_comp/README.html" target="_top"><code class="filename">pkgtools/pkg_comp</code></a>: Build
3277: packages in a chrooted area.</p></li>
3278: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/libkver/README.html" target="_top"><code class="filename">pkgtools/libkver</code></a>: Spoof
3279: kernel version for chrooted cross builds.</p></li>
3280: </ul></div>
3281: </div>
3282: <div class="sect1" lang="en">
3283: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3284: <a name="non-root-pkgsrc"></a>9.4. How to use pkgsrc as non-root</h2></div></div></div>
1.1 dsieger 3285: <p>If you want to use pkgsrc as non-root user, you can set some
3286: variables to make pkgsrc work under these conditions. At the very least,
3287: you need to set <code class="varname">UNPRIVILEGED</code> to “<span class="quote">yes</span>”; this
3288: will turn on unprivileged mode and set multiple related variables to allow
3289: installation of packages as non-root.</p>
3290: <p>In case the defaults are not enough, you may want to tune some other
3291: variables used. For example, if the automatic user/group detection leads
3292: to incorrect values (or not the ones you would like to use), you can change
3293: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
3294: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
3295: <p>As regards bootstrapping, please note that the
1.10 hubertf 3296: <span class="command"><strong>bootstrap</strong></span> script will ease non-root configuration when
1.1 dsieger 3297: given the “<span class="quote">--ignore-user-check</span>” flag, as it will choose and
3298: use multiple default directories under <code class="filename">~/pkg</code> as the
3299: installation targets. These directories can be overridden by the
3300: “<span class="quote">--prefix</span>” flag provided by the script, as well as some others
3301: that allow finer tuning of the tree layout.</p>
3302: </div>
3303: <div class="sect1" lang="en">
3304: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3305: <a name="resume-transfers"></a>9.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
1.1 dsieger 3306: <p>By default, resuming transfers in pkgsrc is disabled, but you can
3307: enable this feature by adding the option
3308: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.10 hubertf 3309: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>. If, during a fetch step, an incomplete
1.1 dsieger 3310: distfile is found, pkgsrc will try to resume it.</p>
3311: <p>You can also
1.10 hubertf 3312: use a different program than the default <a class="citerefentry" 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
1.1 dsieger 3313: <code class="varname">FETCH_CMD</code> variable. Don't forget to set
3314: <code class="varname">FETCH_RESUME_ARGS</code> and
3315: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
3316: values.</p>
3317: <p>For example, if you want to use
3318: <code class="filename">wget</code> to resume downloads, you'll have to use something
3319: like:</p>
3320: <pre class="programlisting">
3321: FETCH_CMD= wget
3322: FETCH_BEFORE_ARGS= --passive-ftp
3323: FETCH_RESUME_ARGS= -c
1.10 hubertf 3324: FETCH_OUTPUT_ARGS= -O -nc
1.1 dsieger 3325: </pre>
3326: </div>
3327: <div class="sect1" lang="en">
3328: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3329: <a name="x.org-from-pkgsrc"></a>9.6. How can I install/use modular X.org from pkgsrc?</h2></div></div></div>
1.4 rillig 3330: <p>If you want to use modular X.org from pkgsrc instead of your system's own X11
1.1 dsieger 3331: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
3332: you will have to add the following line into
1.10 hubertf 3333: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>:</p>
1.1 dsieger 3334: <pre class="programlisting">
1.4 rillig 3335: X11_TYPE=modular
1.1 dsieger 3336: </pre>
3337: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
3338: <h3 class="title">Note</h3>
1.4 rillig 3339: <p>The DragonFly operating system defaults to using modular X.org from pkgsrc.
3340: </p>
1.1 dsieger 3341: </div>
3342: </div>
3343: <div class="sect1" lang="en">
3344: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3345: <a name="fetch-behind-firewall"></a>9.7. How to fetch files from behind a firewall</h2></div></div></div>
1.1 dsieger 3346: <p>If you are sitting behind a firewall which does not allow direct
3347: connections to Internet hosts (i.e. non-NAT), you may specify the
3348: relevant proxy hosts. This is done using an environment variable in the
3349: form of a URL, e.g. in Amdahl, the machine
3350: “<span class="quote">orpheus.amdahl.com</span>” is one of the firewalls, and it uses
3351: port 80 as the proxy port number. So the proxy environment variables
3352: are:</p>
3353: <pre class="programlisting">
3354: ftp_proxy=ftp://orpheus.amdahl.com:80/
3355: http_proxy=http://orpheus.amdahl.com:80/
3356: </pre>
3357: </div>
3358: <div class="sect1" lang="en">
3359: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.10 hubertf 3360: <a name="passive-ftp"></a>9.8. How do I tell <span class="command"><strong>make fetch</strong></span> to do passive FTP?</h2></div></div></div>
1.1 dsieger 3361: <p>This depends on which utility is used to retrieve distfiles. From
3362: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
3363: the first available command from the following list:</p>
3364: <div class="itemizedlist"><ul type="disc">
3365: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
3366: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
3367: </ul></div>
3368: <p>On a default NetBSD installation, this will be
3369: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
3370: connections first, and falls back to active connections if the server
3371: refuses to do passive. For the other tools, add the following to your
1.10 hubertf 3372: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> file:
1.1 dsieger 3373: <code class="varname">PASSIVE_FETCH=1</code>.</p>
3374: <p>Having that option present will prevent
3375: <code class="filename">/usr/bin/ftp</code> from falling back to active
3376: transfers.</p>
3377: </div>
3378: <div class="sect1" lang="en">
3379: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3380: <a name="fetching-all-distfiles"></a>9.9. How to fetch all distfiles at once</h2></div></div></div>
1.1 dsieger 3381: <p>You would like to download all the distfiles in a single batch
1.10 hubertf 3382: from work or university, where you can't run a <span class="command"><strong>make
3383: fetch</strong></span>. There is an archive of distfiles on <a class="ulink" href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/" target="_top">ftp.NetBSD.org</a>,
1.1 dsieger 3384: but downloading the entire directory may not be appropriate.</p>
1.10 hubertf 3385: <p>The answer here is to do a <span class="command"><strong>make fetch-list</strong></span> in
1.1 dsieger 3386: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
3387: resulting list to your machine at work/school and use it there. If you
1.10 hubertf 3388: don't have a NetBSD-compatible <a class="citerefentry" 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
1.1 dsieger 3389: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
3390: URL:</p>
3391: <p>At home:</p>
3392: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
3393: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh</code></strong>
3394: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
3395: <p>At work:</p>
3396: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
3397: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
3398: home.</p>
3399: <p>If you have a machine running NetBSD, and you want to get
3400: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your
3401: machine architecture), you can do so by using the above-mentioned
1.10 hubertf 3402: <span class="command"><strong>make fetch-list</strong></span> approach, or fetch the distfiles
1.1 dsieger 3403: directly by running:</p>
3404: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
3405: <p>If you even decide to ignore
3406: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
3407: by running:</p>
3408: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
3409: </div>
3410: <div class="sect1" lang="en">
3411: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3412: <a name="tmac.andoc-missing"></a>9.10. What does “<span class="quote">Don't know how to make
1.1 dsieger 3413: /usr/share/tmac/tmac.andoc</span>” mean?</h2></div></div></div>
3414: <p>When compiling the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a>
3415: package, you get the error from make that it doesn't know how to make
3416: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
3417: you don't have installed the “<span class="quote">text</span>” set (nroff, ...) from
3418: the NetBSD base distribution on your machine. It is recommended to do
3419: that to format man pages.</p>
3420: <p>In the case of the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a> package, you
3421: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.10 hubertf 3422: environment or in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.</p>
1.1 dsieger 3423: </div>
3424: <div class="sect1" lang="en">
3425: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3426: <a name="bsd.own.mk-missing"></a>9.11. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</h2></div></div></div>
1.1 dsieger 3427: <p>You didn't install the compiler set, <code class="filename">comp.tgz</code>,
3428: when you installed your NetBSD machine. Please get and install it, by
3429: extracting it in <code class="filename">/</code>:</p>
3430: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
3431: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
3432: <p><code class="filename">comp.tgz</code> is part of every NetBSD release. Get
1.10 hubertf 3433: the one that corresponds to your release (determine via <span class="command"><strong>uname
1.1 dsieger 3434: -r</strong></span>).</p>
3435: </div>
3436: <div class="sect1" lang="en">
3437: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3438: <a name="using-sudo-with-pkgsrc"></a>9.12. Using 'sudo' with pkgsrc</h2></div></div></div>
1.1 dsieger 3439: <p>When installing packages as non-root user and using the just-in-time
1.10 hubertf 3440: <a class="citerefentry" 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
1.1 dsieger 3441: password for each required package installed. To avoid this, the sudo
3442: package can be used, which does password caching over a limited time. To
3443: use it, install sudo (either as binary package or from
3444: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/sudo/README.html" target="_top"><code class="filename">security/sudo</code></a>) and then put the
1.10 hubertf 3445: following into your <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>, somewhere
1.1 dsieger 3446: <span class="emphasis"><em>after</em></span> the definition of the
3447: <code class="varname">LOCALBASE</code> variable:</p>
3448: <pre class="programlisting">
3449: .if exists(${LOCALBASE}/bin/sudo)
3450: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
3451: .endif
3452: </pre>
3453: </div>
3454: <div class="sect1" lang="en">
3455: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3456: <a name="faq.conf"></a>9.13. How do I change the location of configuration files?</h2></div></div></div>
1.1 dsieger 3457: <p>As the system administrator, you can choose where configuration files
3458: are installed. The default settings make all these files go into
3459: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
3460: be suboptimal depending on your expectations (e.g., a read-only,
3461: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
3462: configuration of the provided packages).</p>
3463: <p>In order to change the defaults, you can modify the
3464: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.10 hubertf 3465: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>) to point to your preferred configuration
1.1 dsieger 3466: directory; some common examples include <code class="filename">/etc</code> or
3467: <code class="filename">/etc/pkg</code>.</p>
3468: <p>Furthermore, you can change this value on a per-package basis by
3469: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
3470: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
3471: package you would like to modify, that is, the contents of
3472: <code class="varname">PKGBASE</code>.</p>
3473: <p>Note that after changing these settings, you must rebuild and
3474: reinstall any affected packages.</p>
3475: </div>
3476: <div class="sect1" lang="en">
3477: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3478: <a name="audit-packages"></a>9.14. Automated security checks</h2></div></div></div>
1.1 dsieger 3479: <p>Please be aware that there can often be bugs in third-party software,
3480: and some of these bugs can leave a machine vulnerable to exploitation by
3481: attackers. In an effort to lessen the exposure, the NetBSD packages team
3482: maintains a database of known-exploits to packages which have at one time
3483: been included in pkgsrc. The database can be downloaded automatically, and
3484: a security audit of all packages installed on a system can take place. To
1.14 ! jmcneill 3485: do this, refer to the following two tools (installed as part of the
! 3486: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a> package):</p>
1.1 dsieger 3487: <div class="orderedlist"><ol type="1">
3488: <li>
1.10 hubertf 3489: <p><span class="command"><strong>download-vulnerability-list</strong></span>, an easy way to
1.1 dsieger 3490: download a list of the security vulnerabilities information. This list
3491: is kept up to date by the NetBSD security officer and the NetBSD
3492: packages team, and is distributed from the NetBSD ftp server:</p>
1.10 hubertf 3493: <p><a class="ulink" 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>
1.1 dsieger 3494: </li>
1.10 hubertf 3495: <li><p><span class="command"><strong>audit-packages</strong></span>, an easy way to audit the
1.1 dsieger 3496: current machine, checking each vulnerability which is known. If a
3497: vulnerable package is installed, it will be shown by output to stdout,
3498: including a description of the type of vulnerability, and a URL
3499: containing more information.</p></li>
3500: </ol></div>
1.14 ! jmcneill 3501: <p>Use of these tools is strongly recommended! After
! 3502: “<span class="quote">pkg_install</span>” is installed, please read
1.1 dsieger 3503: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
1.14 ! jmcneill 3504: pkg_install</code></strong>.</p>
1.1 dsieger 3505: <p>If this package is installed, pkgsrc builds will use it to
1.10 hubertf 3506: perform a security check before building any package. See <a class="xref" 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
1.1 dsieger 3507: check.</p>
3508: </div>
3509: <div class="sect1" lang="en">
3510: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3511: <a name="ufaq-cflags"></a>9.15. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
1.1 dsieger 3512: <p>When you add your own preferences to the
3513: <code class="varname">CFLAGS</code> variable in your
1.10 hubertf 3514: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>, these flags are passed in
1.1 dsieger 3515: environment variables to the <code class="filename">./configure</code>
1.10 hubertf 3516: scripts and to <a class="citerefentry" 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
1.1 dsieger 3517: <code class="varname">CFLAGS</code> from the environment variable by
3518: overriding them in the <code class="filename">Makefile</code>s of their
3519: package.</p>
3520: <p>Currently there is no solution to this problem. If you
3521: really need the package to use your <code class="varname">CFLAGS</code>
1.10 hubertf 3522: you should run <span class="command"><strong>make patch</strong></span> in the package
1.1 dsieger 3523: directory and then inspect any <code class="filename">Makefile</code> and
3524: <code class="filename">Makefile.in</code> for whether they define
3525: <code class="varname">CFLAGS</code> explicitly. Usually you can remove
3526: these lines. But be aware that some “<span class="quote">smart</span>”
3527: programmers write so bad code that it only works for the
3528: specific combination of <code class="varname">CFLAGS</code> they have
3529: chosen.</p>
3530: </div>
3531: <div class="sect1" lang="en">
3532: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3533: <a name="ufaq-fail"></a>9.16. A package does not build. What shall I do?</h2></div></div></div>
1.1 dsieger 3534: <div class="procedure"><ol type="1">
3535: <li><p>Make sure that your copy of pkgsrc is consistent. A
3536: case that occurs often is that people only update pkgsrc in
3537: parts, because of performance reasons. Since pkgsrc is one large
3538: system, not a collection of many small systems, there are
3539: sometimes changes that only work when the whole pkgsrc tree is
3540: updated.</p></li>
3541: <li><p>Make sure that you don't have any CVS conflicts.
3542: Search for “<span class="quote"><<<<<<</span>” or
3543: “<span class="quote">>>>>>></span>” in all your pkgsrc
3544: files.</p></li>
3545: <li><p>Make sure that you don't have old copies of the packages
1.10 hubertf 3546: extracted. Run <span class="command"><strong>make clean clean-depends</strong></span> to
1.1 dsieger 3547: verify this.</p></li>
3548: <li><p>If the problem still exists, write a mail to the
3549: <code class="literal">pkgsrc-users</code> mailing list.</p></li>
3550: </ol></div>
3551: </div>
3552: <div class="sect1" lang="en">
3553: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3554: <a name="faq.rcs-conflicts"></a>9.17. What does “<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>” mean?</h2></div></div></div>
1.1 dsieger 3555: <p>You have modified a file from pkgsrc, and someone else has
3556: modified that same file afterwards in the CVS repository. Both changes
3557: are in the same region of the file, so when you updated pkgsrc, the
3558: <code class="literal">cvs</code> command marked the conflicting changes in the
3559: file. Because of these markers, the file is no longer a valid
3560: <code class="filename">Makefile</code>.</p>
3561: <p>Have a look at that file, and if you don't need your local changes
1.10 hubertf 3562: anymore, you can remove that file and run <span class="command"><strong>cvs -q update
1.1 dsieger 3563: -dP</strong></span> in that directory to download the current version.</p>
3564: </div>
3565: </div>
3566: </div>
3567: <div class="part" lang="en">
3568: <div class="titlepage"><div><div><h1 class="title">
3569: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
3570: <div class="partintro" lang="en">
3571: <div></div>
3572: <p>This part of the book deals with creating and
3573: modifying packages. It starts with a “<span class="quote">HOWTO</span>”-like
3574: guide on creating a new package. The remaining chapters are more
3575: like a reference manual for pkgsrc.</p>
3576: <div class="toc">
3577: <p><b>Table of Contents</b></p>
3578: <dl>
1.6 rillig 3579: <dt><span class="chapter"><a href="#creating">10. Creating a new pkgsrc package from scratch</a></span></dt>
1.1 dsieger 3580: <dd><dl>
1.6 rillig 3581: <dt><span class="sect1"><a href="#creating.common">10.1. Common types of packages</a></span></dt>
1.1 dsieger 3582: <dd><dl>
1.6 rillig 3583: <dt><span class="sect2"><a href="#creating.perl-module">10.1.1. Perl modules</a></span></dt>
3584: <dt><span class="sect2"><a href="#creating.kde-app">10.1.2. KDE applications</a></span></dt>
1.1 dsieger 3585: </dl></dd>
1.6 rillig 3586: <dt><span class="sect1"><a href="#creating.examples">10.2. Examples</a></span></dt>
3587: <dd><dl><dt><span class="sect2"><a href="#creating.nvu">10.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd>
3588: </dl></dd>
3589: <dt><span class="chapter"><a href="#components">11. Package components - files, directories and contents</a></span></dt>
3590: <dd><dl>
3591: <dt><span class="sect1"><a href="#components.Makefile">11.1. <code class="filename">Makefile</code></a></span></dt>
3592: <dt><span class="sect1"><a href="#components.distinfo">11.2. <code class="filename">distinfo</code></a></span></dt>
3593: <dt><span class="sect1"><a href="#components.patches">11.3. patches/*</a></span></dt>
3594: <dd><dl>
3595: <dt><span class="sect2"><a href="#components.patch.structure">11.3.1. Structure of a single patch file</a></span></dt>
3596: <dt><span class="sect2"><a href="#components.patches.caveats">11.3.2. Creating patch files</a></span></dt>
3597: <dt><span class="sect2"><a href="#components.patches.sources">11.3.3. Sources where the patch files come from</a></span></dt>
3598: <dt><span class="sect2"><a href="#components.patches.guidelines">11.3.4. Patching guidelines</a></span></dt>
3599: <dt><span class="sect2"><a href="#components.patches.feedback">11.3.5. Feedback to the author</a></span></dt>
3600: </dl></dd>
3601: <dt><span class="sect1"><a href="#other-mandatory-files">11.4. Other mandatory files</a></span></dt>
3602: <dt><span class="sect1"><a href="#components.optional">11.5. Optional files</a></span></dt>
3603: <dd><dl>
3604: <dt><span class="sect2"><a href="#components.optional.bin">11.5.1. Files affecting the binary package</a></span></dt>
3605: <dt><span class="sect2"><a href="#components.optional.build">11.5.2. Files affecting the build process</a></span></dt>
3606: <dt><span class="sect2"><a href="#components.optional.none">11.5.3. Files affecting nothing at all</a></span></dt>
3607: </dl></dd>
3608: <dt><span class="sect1"><a href="#work-dir">11.6. <code class="filename">work*</code></a></span></dt>
3609: <dt><span class="sect1"><a href="#files-dir">11.7. <code class="filename">files/*</code></a></span></dt>
3610: </dl></dd>
3611: <dt><span class="chapter"><a href="#makefile">12. Programming in <code class="filename">Makefile</code>s</a></span></dt>
3612: <dd><dl>
3613: <dt><span class="sect1"><a href="#makefile.style">12.1. Caveats</a></span></dt>
3614: <dt><span class="sect1"><a href="#makefile.variables">12.2. <code class="filename">Makefile</code> variables</a></span></dt>
3615: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">12.2.1. Naming conventions</a></span></dt></dl></dd>
3616: <dt><span class="sect1"><a href="#makefile.code">12.3. Code snippets</a></span></dt>
3617: <dd><dl>
3618: <dt><span class="sect2"><a href="#adding-to-list">12.3.1. Adding things to a list</a></span></dt>
3619: <dt><span class="sect2"><a href="#converting-internal-to-external">12.3.2. Converting an internal list into an external list</a></span></dt>
3620: <dt><span class="sect2"><a href="#passing-variable-to-shell">12.3.3. Passing variables to a shell command</a></span></dt>
3621: <dt><span class="sect2"><a href="#quoting-guideline">12.3.4. Quoting guideline</a></span></dt>
3622: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">12.3.5. Workaround for a bug in BSD Make</a></span></dt>
3623: </dl></dd>
3624: </dl></dd>
3625: <dt><span class="chapter"><a href="#plist">13. PLIST issues</a></span></dt>
3626: <dd><dl>
3627: <dt><span class="sect1"><a href="#rcs-id">13.1. RCS ID</a></span></dt>
3628: <dt><span class="sect1"><a href="#automatic-plist-generation">13.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
1.10 hubertf 3629: <dt><span class="sect1"><a href="#print-PLIST">13.3. Tweaking output of <span class="command"><strong>make print-PLIST</strong></span></a></span></dt>
1.6 rillig 3630: <dt><span class="sect1"><a href="#plist.misc">13.4. Variable substitution in PLIST</a></span></dt>
3631: <dt><span class="sect1"><a href="#manpage-compression">13.5. Man page compression</a></span></dt>
3632: <dt><span class="sect1"><a href="#using-PLIST_SRC">13.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
3633: <dt><span class="sect1"><a href="#platform-specific-plist">13.7. Platform-specific and differing PLISTs</a></span></dt>
3634: <dt><span class="sect1"><a href="#faq.common-dirs">13.8. Sharing directories between packages</a></span></dt>
3635: </dl></dd>
3636: <dt><span class="chapter"><a href="#buildlink">14. Buildlink methodology</a></span></dt>
3637: <dd><dl>
3638: <dt><span class="sect1"><a href="#converting-to-buildlink3">14.1. Converting packages to use buildlink3</a></span></dt>
3639: <dt><span class="sect1"><a href="#creating-buildlink3.mk">14.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
3640: <dd><dl>
3641: <dt><span class="sect2"><a href="#anatomy-of-bl3">14.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
3642: <dt><span class="sect2"><a href="#updating-buildlink-depends">14.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>
3643: </dl></dd>
3644: <dt><span class="sect1"><a href="#writing-builtin.mk">14.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
3645: <dd><dl>
3646: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">14.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
3647: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">14.3.2. Global preferences for native or pkgsrc software</a></span></dt>
3648: </dl></dd>
3649: </dl></dd>
3650: <dt><span class="chapter"><a href="#pkginstall">15. The pkginstall framework</a></span></dt>
3651: <dd><dl>
3652: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">15.1. Files and directories outside the installation prefix</a></span></dt>
3653: <dd><dl>
3654: <dt><span class="sect2"><a href="#dirs-outside-prefix">15.1.1. Directory manipulation</a></span></dt>
3655: <dt><span class="sect2"><a href="#files-outside-prefix">15.1.2. File manipulation</a></span></dt>
3656: </dl></dd>
3657: <dt><span class="sect1"><a href="#conf-files">15.2. Configuration files</a></span></dt>
3658: <dd><dl>
3659: <dt><span class="sect2"><a href="#conf-files-sysconfdir">15.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
3660: <dt><span class="sect2"><a href="#conf-files-configure">15.2.2. Telling the software where configuration files are</a></span></dt>
3661: <dt><span class="sect2"><a href="#conf-files-patching">15.2.3. Patching installations</a></span></dt>
3662: <dt><span class="sect2"><a href="#conf-files-disable">15.2.4. Disabling handling of configuration files</a></span></dt>
3663: </dl></dd>
3664: <dt><span class="sect1"><a href="#rcd-scripts">15.3. System startup scripts</a></span></dt>
3665: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">15.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
3666: <dt><span class="sect1"><a href="#users-and-groups">15.4. System users and groups</a></span></dt>
3667: <dt><span class="sect1"><a href="#shells">15.5. System shells</a></span></dt>
3668: <dd><dl><dt><span class="sect2"><a href="#shells-disable">15.5.1. Disabling shell registration</a></span></dt></dl></dd>
3669: <dt><span class="sect1"><a href="#fonts">15.6. Fonts</a></span></dt>
3670: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">15.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
3671: </dl></dd>
3672: <dt><span class="chapter"><a href="#options">16. Options handling</a></span></dt>
3673: <dd><dl>
3674: <dt><span class="sect1"><a href="#global-default-options">16.1. Global default options</a></span></dt>
3675: <dt><span class="sect1"><a href="#converting-to-options">16.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
3676: <dt><span class="sect1"><a href="#option-names">16.3. Option Names</a></span></dt>
1.7 rillig 3677: <dt><span class="sect1"><a href="#option-build">16.4. Determining the options of dependencies</a></span></dt>
1.6 rillig 3678: </dl></dd>
3679: <dt><span class="chapter"><a href="#build">17. The build process</a></span></dt>
3680: <dd><dl>
3681: <dt><span class="sect1"><a href="#build.intro">17.1. Introduction</a></span></dt>
3682: <dt><span class="sect1"><a href="#build.prefix">17.2. Program location</a></span></dt>
3683: <dt><span class="sect1"><a href="#build.builddirs">17.3. Directories used during the build process</a></span></dt>
3684: <dt><span class="sect1"><a href="#build.running">17.4. Running a phase</a></span></dt>
3685: <dt><span class="sect1"><a href="#build.fetch">17.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
3686: <dd><dl>
3687: <dt><span class="sect2"><a href="#build.fetch.what">17.5.1. What to fetch and where to get it from</a></span></dt>
3688: <dt><span class="sect2"><a href="#build.fetch.how">17.5.2. How are the files fetched?</a></span></dt>
3689: </dl></dd>
3690: <dt><span class="sect1"><a href="#build.checksum">17.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
3691: <dt><span class="sect1"><a href="#build.extract">17.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
3692: <dt><span class="sect1"><a href="#build.patch">17.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
3693: <dt><span class="sect1"><a href="#build.tools">17.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
3694: <dt><span class="sect1"><a href="#build.wrapper">17.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
3695: <dt><span class="sect1"><a href="#build.configure">17.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
3696: <dt><span class="sect1"><a href="#build.build">17.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3697: <dt><span class="sect1"><a href="#build.test">17.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
3698: <dt><span class="sect1"><a href="#build.install">17.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3699: <dt><span class="sect1"><a href="#build.package">17.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
3700: <dt><span class="sect1"><a href="#build.clean">17.16. Cleaning up</a></span></dt>
3701: <dt><span class="sect1"><a href="#build.helpful-targets">17.17. Other helpful targets</a></span></dt>
3702: </dl></dd>
3703: <dt><span class="chapter"><a href="#tools">18. Tools needed for building or running</a></span></dt>
3704: <dd><dl>
3705: <dt><span class="sect1"><a href="#pkgsrc-tools">18.1. Tools for pkgsrc builds</a></span></dt>
3706: <dt><span class="sect1"><a href="#package-tools">18.2. Tools needed by packages</a></span></dt>
3707: <dt><span class="sect1"><a href="#platform-tools">18.3. Tools provided by platforms</a></span></dt>
3708: <dt><span class="sect1"><a href="#tools.questions">18.4. Questions regarding the tools</a></span></dt>
3709: </dl></dd>
3710: <dt><span class="chapter"><a href="#fixes">19. Making your package work</a></span></dt>
3711: <dd><dl>
3712: <dt><span class="sect1"><a href="#general-operation">19.1. General operation</a></span></dt>
3713: <dd><dl>
3714: <dt><span class="sect2"><a href="#portability-of-packages">19.1.1. Portability of packages</a></span></dt>
3715: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">19.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
3716: <dt><span class="sect2"><a href="#user-interaction">19.1.3. User interaction</a></span></dt>
3717: <dt><span class="sect2"><a href="#handling-licenses">19.1.4. Handling licenses</a></span></dt>
3718: <dt><span class="sect2"><a href="#restricted-packages">19.1.5. Restricted packages</a></span></dt>
3719: <dt><span class="sect2"><a href="#dependencies">19.1.6. Handling dependencies</a></span></dt>
3720: <dt><span class="sect2"><a href="#conflicts">19.1.7. Handling conflicts with other packages</a></span></dt>
3721: <dt><span class="sect2"><a href="#not-building-packages">19.1.8. Packages that cannot or should not be built</a></span></dt>
3722: <dt><span class="sect2"><a href="#undeletable-packages">19.1.9. Packages which should not be deleted, once installed</a></span></dt>
3723: <dt><span class="sect2"><a href="#security-handling">19.1.10. Handling packages with security problems</a></span></dt>
3724: <dt><span class="sect2"><a href="#bumping-pkgrevision">19.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
3725: <dt><span class="sect2"><a href="#fixes.subst">19.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
3726: </dl></dd>
3727: <dt><span class="sect1"><a href="#fixes.fetch">19.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
3728: <dd><dl>
3729: <dt><span class="sect2"><a href="#no-plain-download">19.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
3730: <dt><span class="sect2"><a href="#modified-distfiles-same-name">19.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
3731: </dl></dd>
3732: <dt><span class="sect1"><a href="#fixes.configure">19.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
3733: <dd><dl>
3734: <dt><span class="sect2"><a href="#fixes.libtool">19.3.1. Shared libraries - libtool</a></span></dt>
3735: <dt><span class="sect2"><a href="#using-libtool">19.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
3736: <dt><span class="sect2"><a href="#autoconf-automake">19.3.3. GNU Autoconf/Automake</a></span></dt>
3737: </dl></dd>
3738: <dt><span class="sect1"><a href="#programming-languages">19.4. Programming languages</a></span></dt>
3739: <dd><dl>
3740: <dt><span class="sect2"><a href="#basic-programming-languages">19.4.1. C, C++, and Fortran</a></span></dt>
3741: <dt><span class="sect2"><a href="#java-programming-language">19.4.2. Java</a></span></dt>
3742: <dt><span class="sect2"><a href="#perl-scripts">19.4.3. Packages containing perl scripts</a></span></dt>
3743: <dt><span class="sect2"><a href="#other-programming-languages">19.4.4. Other programming languages</a></span></dt>
3744: </dl></dd>
3745: <dt><span class="sect1"><a href="#fixes.build">19.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3746: <dd><dl>
3747: <dt><span class="sect2"><a href="#fixes.build.cpp">19.5.1. Compiling C and C++ code conditionally</a></span></dt>
3748: <dt><span class="sect2"><a href="#compiler-bugs">19.5.2. How to handle compiler bugs</a></span></dt>
3749: <dt><span class="sect2"><a href="#undefined-reference">19.5.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
3750: <dt><span class="sect2"><a href="#out-of-memory">19.5.4. Running out of memory</a></span></dt>
3751: </dl></dd>
3752: <dt><span class="sect1"><a href="#fixes.install">19.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3753: <dd><dl>
3754: <dt><span class="sect2"><a href="#install-scripts">19.6.1. Creating needed directories</a></span></dt>
3755: <dt><span class="sect2"><a href="#where-to-install-documentation">19.6.2. Where to install documentation</a></span></dt>
3756: <dt><span class="sect2"><a href="#installing-score-files">19.6.3. Installing highscore files</a></span></dt>
3757: <dt><span class="sect2"><a href="#destdir-support">19.6.4. Adding DESTDIR support to packages</a></span></dt>
3758: <dt><span class="sect2"><a href="#hardcoded-paths">19.6.5. Packages with hardcoded paths to other interpreters</a></span></dt>
3759: <dt><span class="sect2"><a href="#perl-modules">19.6.6. Packages installing perl modules</a></span></dt>
3760: <dt><span class="sect2"><a href="#faq.info-files">19.6.7. Packages installing info files</a></span></dt>
3761: <dt><span class="sect2"><a href="#manpages">19.6.8. Packages installing man pages</a></span></dt>
1.7 rillig 3762: <dt><span class="sect2"><a href="#gconf-data-files">19.6.9. Packages installing GConf data files</a></span></dt>
1.6 rillig 3763: <dt><span class="sect2"><a href="#scrollkeeper-data-files">19.6.10. Packages installing scrollkeeper data files</a></span></dt>
3764: <dt><span class="sect2"><a href="#x11-fonts">19.6.11. Packages installing X11 fonts</a></span></dt>
3765: <dt><span class="sect2"><a href="#gtk2-modules">19.6.12. Packages installing GTK2 modules</a></span></dt>
3766: <dt><span class="sect2"><a href="#sgml-xml-data">19.6.13. Packages installing SGML or XML data</a></span></dt>
3767: <dt><span class="sect2"><a href="#mime-database">19.6.14. Packages installing extensions to the MIME database</a></span></dt>
3768: <dt><span class="sect2"><a href="#intltool">19.6.15. Packages using intltool</a></span></dt>
3769: <dt><span class="sect2"><a href="#startup-scripts">19.6.16. Packages installing startup scripts</a></span></dt>
3770: <dt><span class="sect2"><a href="#tex-packages">19.6.17. Packages installing TeX modules</a></span></dt>
3771: <dt><span class="sect2"><a href="#emulation-packages">19.6.18. Packages supporting running binaries in
1.1 dsieger 3772: emulation</a></span></dt>
1.6 rillig 3773: <dt><span class="sect2"><a href="#hicolor-theme">19.6.19. Packages installing hicolor theme icons</a></span></dt>
3774: <dt><span class="sect2"><a href="#desktop-files">19.6.20. Packages installing desktop files</a></span></dt>
1.1 dsieger 3775: </dl></dd>
1.6 rillig 3776: <dt><span class="sect1"><a href="#punting">19.7. Marking packages as having problems</a></span></dt>
1.1 dsieger 3777: </dl></dd>
1.6 rillig 3778: <dt><span class="chapter"><a href="#debug">20. Debugging</a></span></dt>
3779: <dt><span class="chapter"><a href="#submit">21. Submitting and Committing</a></span></dt>
1.1 dsieger 3780: <dd><dl>
1.6 rillig 3781: <dt><span class="sect1"><a href="#submitting-binary-packages">21.1. Submitting binary packages</a></span></dt>
3782: <dt><span class="sect1"><a href="#submitting-your-package">21.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
3783: <dt><span class="sect1"><a href="#general-notes-for-changes">21.3. General notes when adding, updating, or removing packages</a></span></dt>
3784: <dt><span class="sect1"><a href="#committing-importing">21.4. Committing: Importing a package into CVS</a></span></dt>
3785: <dt><span class="sect1"><a href="#updating-package">21.5. Updating a package to a newer version</a></span></dt>
3786: <dt><span class="sect1"><a href="#moving-package">21.6. Moving a package in pkgsrc</a></span></dt>
3787: </dl></dd>
3788: <dt><span class="chapter"><a href="#devfaq">22. Frequently Asked Questions</a></span></dt>
3789: <dt><span class="chapter"><a href="#gnome">23. GNOME packaging and porting</a></span></dt>
3790: <dd><dl>
3791: <dt><span class="sect1"><a href="#meta-packages">23.1. Meta packages</a></span></dt>
3792: <dt><span class="sect1"><a href="#new-package">23.2. Packaging a GNOME application</a></span></dt>
3793: <dt><span class="sect1"><a href="#full-update">23.3. Updating GNOME to a newer version</a></span></dt>
3794: <dt><span class="sect1"><a href="#patching">23.4. Patching guidelines</a></span></dt>
1.1 dsieger 3795: </dl></dd>
3796: </dl>
3797: </div>
3798: </div>
3799: <div class="chapter" lang="en">
3800: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 3801: <a name="creating"></a>Chapter 10. Creating a new pkgsrc package from scratch</h2></div></div></div>
1.1 dsieger 3802: <div class="toc">
3803: <p><b>Table of Contents</b></p>
3804: <dl>
1.6 rillig 3805: <dt><span class="sect1"><a href="#creating.common">10.1. Common types of packages</a></span></dt>
1.1 dsieger 3806: <dd><dl>
1.6 rillig 3807: <dt><span class="sect2"><a href="#creating.perl-module">10.1.1. Perl modules</a></span></dt>
3808: <dt><span class="sect2"><a href="#creating.kde-app">10.1.2. KDE applications</a></span></dt>
1.1 dsieger 3809: </dl></dd>
1.6 rillig 3810: <dt><span class="sect1"><a href="#creating.examples">10.2. Examples</a></span></dt>
3811: <dd><dl><dt><span class="sect2"><a href="#creating.nvu">10.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd>
1.1 dsieger 3812: </dl>
3813: </div>
3814: <p>When you find a package that is not yet in pkgsrc, you
3815: most likely have a URL from where you can download the source
3816: code. Starting with this URL, creating a package involves only a
3817: few steps.</p>
3818: <div class="procedure"><ol type="1">
3819: <li><p>First, install the packages <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a> and <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>.</p></li>
3820: <li><p>Then, choose one of the top-level directories as the
3821: category in which you want to place your package. You can also create a
3822: directory of your own (maybe called <code class="filename">local</code>). In that
3823: category directory, create another directory for your package and change
3824: into it.</p></li>
1.10 hubertf 3825: <li><p>Run the program <span class="command"><strong>url2pkg</strong></span>, which will ask
1.1 dsieger 3826: you for a URL. Enter the URL of the distribution file (in most cases a
3827: <code class="filename">.tar.gz</code> file) and watch how the basic ingredients
3828: of your package are created automatically. The distribution file is
3829: extracted automatically to fill in some details in the
3830: <code class="filename">Makefile</code> that would otherwise have to be done
3831: manually.</p></li>
3832: <li>
3833: <p>Examine the extracted files to determine the dependencies of
3834: your package. Ideally, this is mentioned in some
3835: <code class="filename">README</code> file, but things may differ. For each of
3836: these dependencies, look where it exists in pkgsrc, and if there is a
3837: file called <code class="filename">buildlink3.mk</code> in that directory, add a
3838: line to your package <code class="filename">Makefile</code> which includes that
3839: file just before the last line. If the
3840: <code class="filename">buildlink3.mk</code> file does not exist, add a
3841: <code class="varname">DEPENDS</code> line to the Makefile, which specifies the
3842: version of the dependency and where it can be found in pkgsrc. This line
3843: should be placed in the third paragraph. If the dependency is only
3844: needed for building the package, but not when using it, use
3845: <code class="varname">BUILD_DEPENDS</code> instead of <code class="varname">DEPENDS</code>.
3846: Your package may then look like this:</p>
3847: <pre class="programlisting">
3848: [...]
3849:
3850: BUILD_DEPENDS+= lua>=5.0:../../lang/lua
3851: DEPENDS+= screen-[0-9]*:../../misc/screen
3852: DEPENDS+= screen>=4.0:../../misc/screen
3853:
3854: [...]
3855:
3856: .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
3857: .include "../../devel/glib2/buildlink3.mk"
3858: .include "../../mk/bsd.pkg.mk"
3859: </pre>
3860: </li>
1.10 hubertf 3861: <li><p>Run <span class="command"><strong>pkglint</strong></span> to see what things still need
1.1 dsieger 3862: to be done to make your package a “<span class="quote">good</span>” one. If you don't
1.10 hubertf 3863: know what pkglint's warnings want to tell you, try <span class="command"><strong>pkglint
3864: --explain</strong></span> or <span class="command"><strong>pkglint
1.1 dsieger 3865: -e</strong></span>, which outputs additional
3866: explanations.</p></li>
3867: <li><p>In many cases the package is not yet ready to build. You can
1.10 hubertf 3868: find instructions for the most common cases in the next section, <a class="xref" href="#creating.common" title="10.1. Common types of packages">Section 10.1, “Common types of packages”</a>. After you have followed the instructions
1.1 dsieger 3869: over there, you can hopefully continue here.</p></li>
1.10 hubertf 3870: <li><p>Run <span class="command"><strong>bmake clean</strong></span> to clean the working
1.1 dsieger 3871: directory from the extracted files. Besides these files, a lot of cache
3872: files and other system information has been saved in the working
3873: directory, which may become wrong after you edited the
3874: <code class="filename">Makefile</code>.</p></li>
1.10 hubertf 3875: <li><p>Now, run <span class="command"><strong>bmake</strong></span> to build the package. For
3876: the various things that can go wrong in this phase, consult <a class="xref" href="#fixes" title="Chapter 19. Making your package work">Chapter 19, <i>Making your package work</i></a>.</p></li>
1.1 dsieger 3877: <li><p>When the package builds fine, the next step is to install
1.10 hubertf 3878: the package. Run <span class="command"><strong>bmake install</strong></span> and hope that
1.1 dsieger 3879: everything works.</p></li>
3880: <li><p>Up to now, the file <code class="filename">PLIST</code>, which
3881: contains a list of the files that are installed by the package, is
1.10 hubertf 3882: nearly empty. Run <span class="command"><strong>bmake print-PLIST
1.1 dsieger 3883: >PLIST</strong></span> to generate a probably correct list. Check
3884: the file using your preferred text editor to see if the list of
3885: files looks plausible.</p></li>
1.10 hubertf 3886: <li><p>Run <span class="command"><strong>pkglint</strong></span> again to see if the generated
1.1 dsieger 3887: <code class="filename">PLIST</code> contains garbage or not.</p></li>
1.10 hubertf 3888: <li><p>When you ran <span class="command"><strong>bmake install</strong></span>, the package
1.1 dsieger 3889: has been registered in the database of installed files, but with an
1.10 hubertf 3890: empty list of files. To fix this, run <span class="command"><strong>bmake deinstall</strong></span>
3891: and <span class="command"><strong>bmake install</strong></span> again. Now the package is
1.1 dsieger 3892: registered with the list of files from
3893: <code class="filename">PLIST</code>.</p></li>
1.10 hubertf 3894: <li><p>Run <span class="command"><strong>bmake package</strong></span> to create a binary
1.1 dsieger 3895: package from the set of installed files.</p></li>
3896: </ol></div>
3897: <div class="sect1" lang="en">
3898: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3899: <a name="creating.common"></a>10.1. Common types of packages</h2></div></div></div>
1.1 dsieger 3900: <div class="sect2" lang="en">
3901: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 3902: <a name="creating.perl-module"></a>10.1.1. Perl modules</h3></div></div></div>
1.1 dsieger 3903: <p>Simple Perl modules are handled automatically by
1.10 hubertf 3904: <span class="command"><strong>url2pkg</strong></span>, including dependencies.</p>
1.1 dsieger 3905: </div>
3906: <div class="sect2" lang="en">
3907: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 3908: <a name="creating.kde-app"></a>10.1.2. KDE applications</h3></div></div></div>
1.1 dsieger 3909: <p>KDE applications should always include
3910: <code class="filename">meta-pkgs/kde3/kde3.mk</code>, which contains numerous
3911: settings that are typical of KDE packages.</p>
3912: </div>
3913: </div>
3914: <div class="sect1" lang="en">
3915: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 3916: <a name="creating.examples"></a>10.2. Examples</h2></div></div></div>
1.1 dsieger 3917: <div class="sect2" lang="en">
3918: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 3919: <a name="creating.nvu"></a>10.2.1. How the www/nvu package came into pkgsrc</h3></div></div></div>
1.1 dsieger 3920: <div class="sect3" lang="en">
3921: <div class="titlepage"><div><div><h4 class="title">
1.6 rillig 3922: <a name="creating.nvu.init"></a>10.2.1.1. The initial package</h4></div></div></div>
1.1 dsieger 3923: <p>Looking at the file <code class="filename">pkgsrc/doc/TODO</code>, I saw
3924: that the “<span class="quote">nvu</span>” package has not yet been imported into
3925: pkgsrc. As the description says it has to do with the web, the obvious
3926: choice for the category is “<span class="quote">www</span>”.</p>
3927: <pre class="programlisting">
3928: <code class="prompt">$</code> mkdir www/nvu
3929: <code class="prompt">$</code> cd www/nvu
3930: </pre>
3931: <p>The web site says that the sources are available as a tar file, so
1.10 hubertf 3932: I fed that URL to the <span class="command"><strong>url2pkg</strong></span> program:</p>
1.1 dsieger 3933: <pre class="programlisting">
3934: <code class="prompt">$</code> url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
3935: </pre>
3936: <p>My editor popped up, and I added a <code class="varname">PKGNAME</code> line
3937: below the <code class="varname">DISTNAME</code> line, as the package name should
3938: not have the word “<span class="quote">sources</span>” in it. I also filled in the
3939: <code class="varname">MAINTAINER</code>, <code class="varname">HOMEPAGE</code> and
3940: <code class="varname">COMMENT</code> fields. Then the package
3941: <code class="filename">Makefile</code> looked like that:</p>
3942: <pre class="programlisting">
3943: # $NetBSD$
3944: #
3945:
3946: DISTNAME= nvu-1.0-sources
3947: PKGNAME= nvu-1.0
3948: CATEGORIES= www
3949: MASTER_SITES= http://cvs.nvu.com/download/
3950: EXTRACT_SUFX= .tar.bz2
3951:
3952: MAINTAINER= rillig@NetBSD.org
3953: HOMEPAGE= http://cvs.nvu.com/
3954: COMMENT= Web Authoring System
3955:
3956: # url2pkg-marker (please do not remove this line.)
3957: .include "../../mk/bsd.pkg.mk"
3958: </pre>
3959: <p>Then, I quit the editor and watched pkgsrc downloading a large
3960: source archive:</p>
3961: <pre class="programlisting">
3962: url2pkg> Running "make makesum" ...
3963: => Required installed package digest>=20010302: digest-20060826 found
3964: => Fetching nvu-1.0-sources.tar.bz2
3965: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
3966: 100% |*************************************| 28992 KB 150.77 KB/s00:00 ETA
3967: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
3968: url2pkg> Running "make extract" ...
3969: => Required installed package digest>=20010302: digest-20060826 found
3970: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
3971: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
3972: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
3973: ===> Installing dependencies for nvu-1.0
3974: ===> Overriding tools for nvu-1.0
3975: ===> Extracting for nvu-1.0
3976: url2pkg> Adjusting the Makefile.
3977:
3978: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
3979:
3980: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
3981: </pre>
3982: </div>
3983: <div class="sect3" lang="en">
3984: <div class="titlepage"><div><div><h4 class="title">
1.6 rillig 3985: <a name="creating.nvu.problems"></a>10.2.1.2. Fixing all kinds of problems to make the package work</h4></div></div></div>
1.1 dsieger 3986: <p>Now that the package has been extracted, let's see what's inside
3987: it. The package has a <code class="filename">README.txt</code>, but that only
3988: says something about mozilla, so it's probably useless for seeing what
3989: dependencies this package has. But since there is a GNU configure script
3990: in the package, let's hope that it will complain about everything it
3991: needs.</p>
3992: <pre class="programlisting">
3993: <code class="prompt">$</code> bmake
3994: => Required installed package digest>=20010302: digest-20060826 found
3995: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
3996: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
3997: ===> Patching for nvu-1.0
3998: ===> Creating toolchain wrappers for nvu-1.0
3999: ===> Configuring for nvu-1.0
4000: [...]
4001: configure: error: Perl 5.004 or higher is required.
4002: [...]
4003: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
4004: [...]
4005: </pre>
4006: <p>That worked quite well. So I opened the package Makefile in my
4007: editor, and since it already has a <code class="varname">USE_TOOLS</code> line, I
4008: just appended “<span class="quote">perl</span>” to it. Since the dependencies of the
4009: package have changed now, and since a perl wrapper is automatically
4010: installed in the “<span class="quote">tools</span>” phase, I need to build the package
4011: from scratch.</p>
4012: <pre class="programlisting">
4013: <code class="prompt">$</code> bmake clean
4014: ===> Cleaning for nvu-1.0
4015: <code class="prompt">$</code> bmake
4016: [...]
4017: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
4018: GNU Make. You will not be able to build Mozilla without GNU Make.
4019: [...]
4020: </pre>
4021: <p>So I added “<span class="quote">gmake</span>” to the
4022: <code class="varname">USE_TOOLS</code> line and tried again (from scratch).</p>
4023: <pre class="programlisting">
4024: [...]
4025: checking for GTK - version >= 1.2.0... no
4026: *** Could not run GTK test program, checking why...
4027: [...]
4028: </pre>
4029: <p>Now to the other dependencies. The first question is: Where is the
4030: GTK package hidden in pkgsrc?</p>
4031: <pre class="programlisting">
4032: <code class="prompt">$</code> echo ../../*/gtk*
4033: [many packages ...]
4034: <code class="prompt">$</code> echo ../../*/gtk
4035: ../../x11/gtk
4036: <code class="prompt">$</code> echo ../../*/gtk2
4037: ../../x11/gtk2
4038: <code class="prompt">$</code> echo ../../*/gtk2/bui*
4039: ../../x11/gtk2/buildlink3.mk
4040: </pre>
4041: <p>The first try was definitely too broad. The second one had exactly
4042: one result, which is very good. But there is one pitfall with GNOME
4043: packages. Before GNOME 2 had been released, there were already many
4044: GNOME 1 packages in pkgsrc. To be able to continue to use these
4045: packages, the GNOME 2 packages were imported as separate packages, and
4046: their names usually have a “<span class="quote">2</span>” appended. So I checked
4047: whether this was the case here, and indeed it was.</p>
4048: <p>Since the GTK2 package has a <code class="filename">buildlink3.mk</code>
4049: file, adding the dependency is very easy. I just inserted an
4050: <code class="literal">.include</code> line before the last line of the package
4051: <code class="filename">Makefile</code>, so that it now looks like this:</p>
4052: <pre class="programlisting">
4053: [...]
4054: .include "../../x11/gtk2/buildlink3.mk"
4055: .include "../../mk/bsd.pkg.mk
4056: </pre>
1.10 hubertf 4057: <p>After another <span class="command"><strong>bmake clean && bmake</strong></span>, the answer
1.1 dsieger 4058: was:</p>
4059: <pre class="programlisting">
4060: [...]
4061: checking for gtk-config... /home/roland/pkg/bin/gtk-config
4062: checking for GTK - version >= 1.2.0... no
4063: *** Could not run GTK test program, checking why...
4064: *** The test program failed to compile or link. See the file config.log for the
4065: *** exact error that occured. This usually means GTK was incorrectly installed
4066: *** or that you have moved GTK since it was installed. In the latter case, you
4067: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
4068: configure: error: Test for GTK failed.
4069: [...]
4070: </pre>
4071: <p>In this particular case, the assumption that “<span class="quote">every package
4072: prefers GNOME 2</span>” had been wrong. The first of the lines above
4073: told me that this package really wanted to have the GNOME 1 version of
4074: GTK. If the package had looked for GTK2, it would have looked for
1.10 hubertf 4075: <span class="command"><strong>pkg-config</strong></span> instead of <span class="command"><strong>gtk-config</strong></span>.
1.1 dsieger 4076: So I changed the <code class="literal">x11/gtk2</code> to
4077: <code class="literal">x11/gtk</code> in the package <code class="filename">Makefile</code>,
4078: and tried again.</p>
4079: <pre class="programlisting">
4080: [...]
4081: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\" -I../../../dist/include/xpcom -I../../../dist/include -I/tmp/roland/pkgsrc/www/nvu/work.bacc/mozilla/dist/include/nspr -I/usr/X11R6/include -fPIC -DPIC -I/home/roland/pkg/include -I/usr/include -I/usr/X11R6/include -Wall -W -Wno-unused -Wpointer-arith -Wcast-align -Wno-long-long -pedantic -O2 -I/home/roland/pkg/include -I/usr/include -Dunix -pthread -pipe -DDEBUG -D_DEBUG -DDEBUG_roland -DTRACING -g -I/home/roland/pkg/include/glib/glib-1.2 -I/home/roland/pkg/lib/glib/include -I/usr/pkg/include/orbit-1.0 -I/home/roland/pkg/include -I/usr/include -I/usr/X11R6/include -include ../../../mozilla-config.h -DMOZILLA_CLIENT -Wp,-MD,.deps/xpidl.pp xpidl.c
4082: In file included from xpidl.c:42:
4083: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
4084: In file included from xpidl.c:42:
4085: xpidl.h:132: error: parse error before "IDL_ns"
4086: [...]
4087: </pre>
4088: <p>The package still does not find all of its dependencies. Now the
4089: question is: Which package provides the
4090: <code class="filename">libIDL/IDL.h</code> header file?</p>
4091: <pre class="programlisting">
4092: <code class="prompt">$</code> echo ../../*/*idl*
4093: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
4094: <code class="prompt">$</code> echo ../../*/*IDL*
4095: ../../net/libIDL
4096: </pre>
4097: <p>Let's take the one from the second try. So I included the
4098: <code class="filename">../../net/libIDL/buildlink3.mk</code> file and tried
4099: again. But the error didn't change. After digging through some of the
4100: code, I concluded that the build process of the package was broken and
4101: couldn't have ever worked, but since the Mozilla source tree is quite
4102: large, I didn't want to fix it. So I added the following to the package
4103: <code class="filename">Makefile</code> and tried again:</p>
4104: <pre class="programlisting">
4105: CPPFLAGS+= -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
4106: BUILDLINK_TRANSFORM+= -l:IDL:IDL-2
4107: </pre>
4108: <p>The latter line is needed because the package expects the library
4109: <code class="filename">libIDL.so</code>, but only
4110: <code class="filename">libIDL-2.so</code> is available. So I told the compiler
4111: wrapper to rewrite that on the fly.</p>
4112: <p>The next problem was related to a recent change of the FreeType
4113: interface. I looked up in <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/seamonkey/README.html" target="_top"><code class="filename">www/seamonkey</code></a>
4114: which patch files were relevant for this issue and copied them to the
4115: <code class="filename">patches</code> directory. Then I retried, fixed the
4116: patches so that they applied cleanly and retried again. This time,
4117: everything worked.</p>
4118: </div>
4119: <div class="sect3" lang="en">
4120: <div class="titlepage"><div><div><h4 class="title">
1.6 rillig 4121: <a name="creating.nvu.inst"></a>10.2.1.3. Installing the package</h4></div></div></div>
1.1 dsieger 4122: <pre class="programlisting">
4123: <code class="prompt">$</code> bmake CHECK_FILES=no install
4124: [...]
4125: <code class="prompt">$</code> bmake print-PLIST >PLIST
4126: <code class="prompt">$</code> bmake deinstall
4127: <code class="prompt">$</code> bmake install
4128: </pre>
4129: </div>
4130: </div>
4131: </div>
4132: </div>
4133: <div class="chapter" lang="en">
4134: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 4135: <a name="components"></a>Chapter 11. Package components - files, directories and contents</h2></div></div></div>
1.1 dsieger 4136: <div class="toc">
4137: <p><b>Table of Contents</b></p>
4138: <dl>
1.6 rillig 4139: <dt><span class="sect1"><a href="#components.Makefile">11.1. <code class="filename">Makefile</code></a></span></dt>
4140: <dt><span class="sect1"><a href="#components.distinfo">11.2. <code class="filename">distinfo</code></a></span></dt>
4141: <dt><span class="sect1"><a href="#components.patches">11.3. patches/*</a></span></dt>
4142: <dd><dl>
4143: <dt><span class="sect2"><a href="#components.patch.structure">11.3.1. Structure of a single patch file</a></span></dt>
4144: <dt><span class="sect2"><a href="#components.patches.caveats">11.3.2. Creating patch files</a></span></dt>
4145: <dt><span class="sect2"><a href="#components.patches.sources">11.3.3. Sources where the patch files come from</a></span></dt>
4146: <dt><span class="sect2"><a href="#components.patches.guidelines">11.3.4. Patching guidelines</a></span></dt>
4147: <dt><span class="sect2"><a href="#components.patches.feedback">11.3.5. Feedback to the author</a></span></dt>
4148: </dl></dd>
4149: <dt><span class="sect1"><a href="#other-mandatory-files">11.4. Other mandatory files</a></span></dt>
4150: <dt><span class="sect1"><a href="#components.optional">11.5. Optional files</a></span></dt>
4151: <dd><dl>
4152: <dt><span class="sect2"><a href="#components.optional.bin">11.5.1. Files affecting the binary package</a></span></dt>
4153: <dt><span class="sect2"><a href="#components.optional.build">11.5.2. Files affecting the build process</a></span></dt>
4154: <dt><span class="sect2"><a href="#components.optional.none">11.5.3. Files affecting nothing at all</a></span></dt>
1.1 dsieger 4155: </dl></dd>
1.6 rillig 4156: <dt><span class="sect1"><a href="#work-dir">11.6. <code class="filename">work*</code></a></span></dt>
4157: <dt><span class="sect1"><a href="#files-dir">11.7. <code class="filename">files/*</code></a></span></dt>
1.1 dsieger 4158: </dl>
4159: </div>
4160: <p>Whenever you're preparing a package, there are a number of
4161: files involved which are described in the following
4162: sections.</p>
4163: <div class="sect1" lang="en">
4164: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 4165: <a name="components.Makefile"></a>11.1. <code class="filename">Makefile</code>
1.1 dsieger 4166: </h2></div></div></div>
4167: <p>Building, installation and creation of a binary package are all
4168: controlled by the package's <code class="filename">Makefile</code>.
4169: The <code class="filename">Makefile</code> describes various things about
4170: a package, for example from where to get it, how to configure,
4171: build, and install it.</p>
4172: <p>A package <code class="filename">Makefile</code> contains several
4173: sections that describe the package.</p>
4174: <p>In the first section there are the following variables, which
4175: should appear exactly in the order given here. The order and
4176: grouping of the variables is mostly historical and has no further
4177: meaning.</p>
4178: <div class="itemizedlist"><ul type="disc">
4179: <li><p><code class="varname">DISTNAME</code> is the basename of the
4180: distribution file to be downloaded from the package's
4181: website.</p></li>
4182: <li><p><code class="varname">PKGNAME</code> is the name of the
4183: package, as used by pkgsrc. You only need to provide it if
4184: <code class="varname">DISTNAME</code> (which is the default) is not a good
4185: name for the package in pkgsrc. Usually it is the pkgsrc
4186: directory name together with the version number. It must match the
4187: regular expression
4188: <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
4189: starts with a letter or digit, and contains only letters, digits,
4190: dashes, underscores, dots and plus signs.</p></li>
4191: <li><p><code class="varname">SVR4_PKGNAME</code> is the name of
4192: the package file to create if the <code class="varname">PKGNAME</code>
4193: isn't unique on a SVR4 system. The default is
4194: <code class="varname">PKGNAME</code>, which may be shortened when you use
4195: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/gensolpkg/README.html" target="_top"><code class="filename">pkgtools/gensolpkg</code></a>. Only add
4196: <code class="varname">SVR4_PKGNAME</code> if <code class="varname">PKGNAME</code>
4197: does not produce an unique package name on a SVR4 system.
4198: The length of <code class="varname">SVR4_PKGNAME</code> is limited to 5
4199: characters.</p></li>
4200: <li>
4201: <p><code class="varname">CATEGORIES</code> is a list of categories
4202: which the package fits in. You can choose any of the top-level
4203: directories of pkgsrc for it.</p>
4204: <p>Currently the following values are available for
4205: <code class="varname">CATEGORIES</code>. If more than
4206: one is used, they need to be separated by spaces:</p>
4207: <pre class="programlisting">
4208: archivers cross geography meta-pkgs security
4209: audio databases graphics misc shells
4210: benchmarks devel ham multimedia sysutils
4211: biology editors inputmethod net textproc
4212: cad emulators lang news time
4213: chat finance mail parallel wm
4214: comms fonts math pkgtools www
4215: converters games mbone print x11
4216: </pre>
4217: </li>
4218: <li><p><code class="varname">MASTER_SITES</code>,
4219: <code class="varname">DYNAMIC_MASTER_SITES</code>,
4220: <code class="varname">DIST_SUBDIR</code>, <code class="varname">EXTRACT_SUFX</code>
4221: and <code class="varname">DISTFILES</code> are discussed in detail in
1.10 hubertf 4222: <a class="xref" href="#build.fetch" title="17.5. The fetch phase">Section 17.5, “The <span class="emphasis"><em>fetch</em></span> phase”</a>.</p></li>
1.1 dsieger 4223: </ul></div>
4224: <p>The second section contains information about separately
4225: downloaded patches, if any.
4226: </p>
4227: <div class="itemizedlist"><ul type="disc">
4228: <li><p><code class="varname">PATCHFILES:</code>
4229: Name(s) of additional files that contain distribution patches.
4230: There is no default. pkgsrc will look for them at
4231: <code class="varname">PATCH_SITES</code>.
4232: They will automatically be uncompressed before patching if
4233: the names end with <code class="filename">.gz</code> or
4234: <code class="filename">.Z</code>.</p></li>
4235: <li><p><code class="varname">PATCH_SITES</code>:
4236: Primary location(s) for distribution patch files (see
4237: <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
4238: </ul></div>
4239: <p>The third section contains the following variables.
4240: </p>
4241: <div class="itemizedlist"><ul type="disc">
1.14 ! jmcneill 4242: <li><p><code class="varname">MAINTAINER</code> is the email
! 4243: address of the person who feels responsible for this package,
! 4244: and who is most likely to look at problems or questions regarding
! 4245: this package which have been reported with <a class="citerefentry" 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>.
! 4246: Other developers may contact the <code class="varname">MAINTAINER</code>
! 4247: before making changes to the package, but are not required to
! 4248: do so. When packaging a new program, set <code class="varname">MAINTAINER</code>
! 4249: to yourself. If you really can't maintain the package for future
! 4250: updates, set it to
1.10 hubertf 4251: <code class="email"><<a class="email" href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>></code>.</p></li>
1.14 ! jmcneill 4252: <li><p><code class="varname">OWNER</code> should be used instead
! 4253: of <code class="varname">MAINTAINER</code> when you do not want other
! 4254: developers to update or change the package without contacting
! 4255: you first. A package Makefile should contain one of
! 4256: <code class="varname">MAINTAINER</code> or <code class="varname">OWNER</code>, but
! 4257: not both. </p></li>
1.1 dsieger 4258: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
4259: find more information about the package.</p></li>
4260: <li><p><code class="varname">COMMENT</code> is a one-line
4261: description of the package (should not include the package
4262: name).</p></li>
4263: </ul></div>
4264: <p>Other variables that affect the build:
4265: </p>
4266: <div class="itemizedlist"><ul type="disc"><li>
4267: <p><code class="varname">WRKSRC</code>: The directory where the
4268: interesting distribution files of the package are found. The
4269: default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
4270: works for most packages.</p>
4271: <p>If a package doesn't create a subdirectory for itself
4272: (most GNU software does, for instance), but extracts itself in
4273: the current directory, you should set
4274: <code class="varname">WRKSRC=${WRKDIR}</code>.</p>
4275: <p>If a package doesn't create a subdirectory with the
4276: name of <code class="varname">DISTNAME</code> but some different name,
4277: set <code class="varname">WRKSRC</code> to point to the proper name in
4278: <code class="filename">${WRKDIR}</code>, for example
4279: <code class="varname">WRKSRC=${WRKDIR}/${DISTNAME}/unix</code>. See
4280: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/lang/tcl/README.html" target="_top"><code class="filename">lang/tcl</code></a> and <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/tk/README.html" target="_top"><code class="filename">x11/tk</code></a> for other examples.</p>
4281: <p>The name of the working directory created by pkgsrc is
4282: taken from the <code class="varname">WRKDIR_BASENAME</code>
4283: variable. By default, its value is
4284: <code class="filename">work</code>. If you want to use the same
4285: pkgsrc tree for building different kinds of binary packages,
4286: you can change the variable according to your needs. Two
4287: other variables handle common cases of setting
4288: <code class="varname">WRKDIR_BASENAME</code> individually. If
4289: <code class="varname">OBJHOSTNAME</code> is defined in
1.10 hubertf 4290: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>, the first component of
1.1 dsieger 4291: the host's name is attached to the directory name. If
4292: <code class="varname">OBJMACHINE</code> is defined, the platform name
4293: is attached, which might look like
4294: <code class="filename">work.i386</code> or
4295: <code class="filename">work.sparc</code>.</p>
4296: </li></ul></div>
4297: <p>Please pay attention to the following gotchas:</p>
4298: <div class="itemizedlist"><ul type="disc">
4299: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are
4300: installed in compressed form by the package. For packages using
4301: BSD-style makefiles which honor MANZ, there is
4302: <code class="varname">MANCOMPRESSED_IF_MANZ</code>.</p></li>
4303: <li><p>Replace <code class="filename">/usr/local</code> with
4304: “<span class="quote">${PREFIX}</span>” in all files (see patches,
4305: below).</p></li>
1.10 hubertf 4306: <li><p>If the package installs any info files, see <a class="xref" href="#faq.info-files" title="19.6.7. Packages installing info files">Section 19.6.7, “Packages installing info files”</a>.</p></li>
1.1 dsieger 4307: </ul></div>
4308: </div>
4309: <div class="sect1" lang="en">
4310: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 4311: <a name="components.distinfo"></a>11.2. <code class="filename">distinfo</code>
1.1 dsieger 4312: </h2></div></div></div>
4313: <p>The <code class="filename">distinfo</code> file contains the message
4314: digest, or checksum, of each distfile needed for the package. This
4315: ensures that the distfiles retrieved from the Internet have not been
4316: corrupted during transfer or altered by a malign force to introduce
4317: a security hole. Due to recent rumor about weaknesses of digest
4318: algorithms, all distfiles are protected using both SHA1 and RMD160
4319: message digests, as well as the file size.</p>
4320: <p>The <code class="filename">distinfo</code> file also contains the
4321: checksums for all the patches found in the
1.10 hubertf 4322: <code class="filename">patches</code> directory (see <a class="xref" href="#components.patches" title="11.3. patches/*">Section 11.3, “patches/*”</a>).</p>
1.1 dsieger 4323: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.10 hubertf 4324: <span class="command"><strong>make makedistinfo</strong></span> or <span class="command"><strong>make mdi</strong></span>
1.1 dsieger 4325: command.</p>
4326: <p>Some packages have different sets of distfiles depending on
4327: the platform, for example <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/navigator/README.html" target="_top"><code class="filename">www/navigator</code></a>). These are kept in the same
4328: <code class="filename">distinfo</code> file and care should be taken when
4329: upgrading such a package to ensure distfile information is not
4330: lost.</p>
4331: </div>
4332: <div class="sect1" lang="en">
4333: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 4334: <a name="components.patches"></a>11.3. patches/*</h2></div></div></div>
1.1 dsieger 4335: <p>Many packages still don't work out-of-the box on the various
4336: platforms that are supported by pkgsrc. Therefore, a number of custom
4337: patch files are needed to make the package work. These patch files are
4338: found in the <code class="filename">patches/</code> directory.</p>
4339: <p>In the <span class="emphasis"><em>patch</em></span> phase, these patches are
4340: applied to the files in <code class="varname">WRKSRC</code> directory after
1.10 hubertf 4341: extracting them, in <a class="ulink" href="http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_13_03" target="_top">alphabetic
1.1 dsieger 4342: order</a>, so <code class="filename">patch-aa</code> is applied before
4343: <code class="filename">patch-ab</code>, etc.</p>
4344: <div class="sect2" lang="en">
4345: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 4346: <a name="components.patch.structure"></a>11.3.1. Structure of a single patch file</h3></div></div></div>
1.1 dsieger 4347: <p>The <code class="filename">patch-*</code> files should be in
1.10 hubertf 4348: <span class="command"><strong>diff -bu</strong></span> format, and apply without a fuzz to avoid
1.1 dsieger 4349: problems. (To force patches to apply with fuzz you can set
4350: <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>). Furthermore, each patch
4351: should contain only changes for a single file, and no file should be
4352: patched by more than one patch file. This helps to keep future
4353: modifications simple.</p>
4354: <p>Each patch file is structured as follows: In the first line,
4355: there is the RCS Id of the patch itself. The second line should be
4356: empty for aesthetic reasons. After that, there should be a comment for
4357: each change that the patch does. There are a number of standard
4358: cases:</p>
4359: <div class="itemizedlist"><ul type="disc">
4360: <li><p>Patches that replace the <code class="literal">==</code>
1.10 hubertf 4361: operator for <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?test+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">test</span>(1)</span></a> with <code class="literal">=</code> in shell scripts
1.11 rillig 4362: are so common that they don't need a comment at all.</p></li>
1.1 dsieger 4363: <li><p>Patches for commonly known vulnerabilities should
4364: mention the vulnerability ID (CAN, CVE).</p></li>
4365: <li><p>Patches that change source code should mention the
4366: platform and other environment (for example, the compiler) that the
4367: patch is needed for.</p></li>
4368: </ul></div>
4369: <p>In all other cases, the patch should be commented so that any
4370: developer who knows the code of the application can make some use of
4371: the patch. Special care should be taken for the upstream developers,
4372: since we generally want that they accept our patches, so we have less
4373: work in the future.</p>
4374: </div>
4375: <div class="sect2" lang="en">
4376: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 4377: <a name="components.patches.caveats"></a>11.3.2. Creating patch files</h3></div></div></div>
1.1 dsieger 4378: <p>One important thing to mention is to pay attention that no RCS
4379: IDs get stored in the patch files, as these will cause problems when
4380: later checked into the NetBSD CVS tree. Use the
1.10 hubertf 4381: <span class="command"><strong>pkgdiff</strong></span> command from the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a> package to avoid these
1.1 dsieger 4382: problems.</p>
4383: <p>For even more automation, we recommend using
1.10 hubertf 4384: <span class="command"><strong>mkpatches</strong></span> from the same package to make a
1.1 dsieger 4385: whole set of patches. You just have to backup files before you
4386: edit them to <code class="filename">filename.orig</code>, e.g. with
1.10 hubertf 4387: <span class="command"><strong>cp -p filename filename.orig</strong></span> or, easier, by
4388: using <span class="command"><strong>pkgvi</strong></span> again from the same package. If
1.1 dsieger 4389: you upgrade a package this way, you can easily compare the new
4390: set of patches with the previously existing one with
1.10 hubertf 4391: <span class="command"><strong>patchdiff</strong></span>. Copy the patches you want to use
1.1 dsieger 4392: or update from the <code class="filename">work/.newpatches</code>
4393: directory to <code class="filename">patches/</code>.</p>
4394: <p>When you have finished a package, remember to generate
1.10 hubertf 4395: the checksums for the patch files by using the <span class="command"><strong>make
4396: makepatchsum</strong></span> command, see <a class="xref" href="#components.distinfo" title="11.2. distinfo">Section 11.2, “<code class="filename">distinfo</code>”</a>.</p>
1.1 dsieger 4397: <p>When adding a patch that corrects a problem in the
4398: distfile (rather than e.g. enforcing pkgsrc's view of where
4399: man pages should go), send the patch as a bug report to the
4400: maintainer. This benefits non-pkgsrc users of the package,
4401: and usually makes it possible to remove the patch in future
4402: version.</p>
1.2 rillig 4403: <p>The file names of the patch files are usually of the form
4404: <code class="filename">patch-<em class="replaceable"><code>[a-z][a-z]</code></em></code>.</p>
1.1 dsieger 4405: </div>
4406: <div class="sect2" lang="en">
4407: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 4408: <a name="components.patches.sources"></a>11.3.3. Sources where the patch files come from</h3></div></div></div>
1.1 dsieger 4409: <p>If you want to share patches between multiple packages
4410: in pkgsrc, e.g. because they use the same distfiles, set
4411: <code class="varname">PATCHDIR</code> to the path where the patch files
4412: can be found, e.g.:</p>
4413: <pre class="programlisting">
4414: PATCHDIR= ${.CURDIR}/../xemacs/patches
4415: </pre>
4416: <p>Patch files that are distributed by the author or other
4417: maintainers can be listed in
4418: <code class="varname">PATCHFILES</code>.</p>
4419: <p>If it is desired to store any patches that should not be
4420: committed into pkgsrc, they can be kept outside the pkgsrc
4421: tree in the <code class="filename">$LOCALPATCHES</code> directory. The
4422: directory tree there is expected to have the same
4423: “<span class="quote">category/package</span>” structure as pkgsrc, and
4424: patches are expected to be stored inside these dirs (also
4425: known as <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
4426: example, if you want to keep a private patch for
4427: <code class="filename">pkgsrc/graphics/png</code>, keep it in
4428: <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
4429: files in the named directory are expected to be patch files,
4430: and <span class="emphasis"><em>they are applied after pkgsrc patches are
4431: applied</em></span>.</p>
4432: </div>
4433: <div class="sect2" lang="en">
4434: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 4435: <a name="components.patches.guidelines"></a>11.3.4. Patching guidelines</h3></div></div></div>
1.1 dsieger 4436: <p>When fixing a portability issue in the code do not use
4437: preprocessor magic to check for the current operating system nor
4438: platform. Doing so hurts portability to other platforms because
4439: the OS-specific details are not abstracted appropriately.</p>
4440: <p>The general rule to follow is: instead of checking for the
4441: operating system the application is being built on, check for the
4442: specific <span class="emphasis"><em>features</em></span> you need. For example,
4443: instead of assuming that kqueue is available under NetBSD and
4444: using the <code class="varname">__NetBSD__</code> macro to conditionalize
1.14 ! jmcneill 4445: kqueue support, add a check that detects kqueue itself —
1.1 dsieger 4446: yes, this generally involves patching the
1.10 hubertf 4447: <span class="command"><strong>configure</strong></span> script. There is absolutely nothing
1.1 dsieger 4448: that prevents some OSes from adopting interfaces from other OSes
4449: (e.g. Linux implementing kqueue), something that the above checks
4450: cannot take into account.</p>
4451: <p>Of course, checking for features generally involves more
4452: work on the developer's side, but the resulting changes are
4453: cleaner and there are chances they will work on many other
4454: platforms. Not to mention that there are higher chances of being
4455: later integrated into the mainstream sources. Remember:
4456: <span class="emphasis"><em>It doesn't work unless it is right!</em></span></p>
4457: <p>Some typical examples:</p>
4458: <div class="table">
1.6 rillig 4459: <a name="patch-examples"></a><p class="title"><b>Table 11.1. Patching examples</b></p>
1.1 dsieger 4460: <div class="table-contents"><table summary="Patching examples" border="1">
4461: <colgroup>
4462: <col>
4463: <col>
4464: <col>
4465: </colgroup>
4466: <thead><tr>
4467: <th>Where</th>
4468: <th>Incorrect</th>
4469: <th>Correct</th>
4470: </tr></thead>
4471: <tbody>
4472: <tr>
4473: <td>configure script</td>
4474: <td>
4475: <pre class="programlisting">
4476: case ${target_os} in
4477: netbsd*) have_kvm=yes ;;
4478: *) have_kvm=no ;;
4479: esac
4480: </pre>
4481: </td>
4482: <td>
4483: <pre class="programlisting">
4484: AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)
4485: </pre>
4486: </td>
4487: </tr>
4488: <tr>
4489: <td>C source file</td>
4490: <td>
4491: <pre class="programlisting">
4492: #if defined(__NetBSD__)
4493: # include <sys/event.h>
4494: #endif
4495: </pre>
4496: </td>
4497: <td>
4498: <pre class="programlisting">
4499: #if defined(HAVE_SYS_EVENT_H)
4500: # include <sys/event.h>
4501: #endif
4502: </pre>
4503: </td>
4504: </tr>
4505: <tr>
4506: <td>C source file</td>
4507: <td>
4508: <pre class="programlisting">
4509: int
4510: monitor_file(...)
4511: {
4512: #if defined(__NetBSD__)
4513: int fd = kqueue();
4514: ...
4515: #else
4516: ...
4517: #endif
4518: }
4519: </pre>
4520: </td>
4521: <td>
4522: <pre class="programlisting">
4523: int
4524: monitor_file(...)
4525: {
4526: #if defined(HAVE_KQUEUE)
4527: int fd = kqueue();
4528: ...
4529: #else
4530: ...
4531: #endif
4532: }
4533: </pre>
4534: </td>
4535: </tr>
4536: </tbody>
4537: </table></div>
4538: </div>
4539: <br class="table-break"><p>For more information, please read the <span class="emphasis"><em>Making
1.10 hubertf 4540: packager-friendly software</em></span> article (<a class="ulink" href="http://www.onlamp.com/pub/a/onlamp/2005/03/31/packaging.html" target="_top">part
4541: 1</a>, <a class="ulink" href="http://www.oreillynet.com/pub/a/onlamp/2005/04/28/packaging2.html" target="_top">part
1.1 dsieger 4542: 2</a>). It summarizes multiple details on how to make
4543: software easier to package; all the suggestions in it were
4544: collected from our experience in pkgsrc work, so they are possibly
4545: helpful when creating patches too.</p>
4546: </div>
4547: <div class="sect2" lang="en">
4548: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 4549: <a name="components.patches.feedback"></a>11.3.5. Feedback to the author</h3></div></div></div>
1.1 dsieger 4550: <p>Always, always, <span class="strong"><strong>always</strong></span>
4551: feed back any <span class="emphasis"><em>portability fixes</em></span> or
4552: improvements you do to a package to the mainstream developers.
4553: This is the only way to get their attention on portability issues
4554: and to ensure that future versions can be built out-of-the box on
4555: NetBSD. Furthermore, any user that gets newer distfiles will get
4556: the fixes straight from the packaged code.</p>
4557: <p>This generally involves cleaning up the patches
4558: (because sometimes the patches that are
4559: added to pkgsrc are quick hacks), filling bug reports in the
4560: appropriate trackers for the projects and working with the
4561: mainstream authors to accept your changes. It is
4562: <span class="emphasis"><em>extremely important</em></span> that you do it so that
4563: the packages in pkgsrc are kept simple and thus further changes
4564: can be done without much hassle.</p>
4565: <p>Support the idea of free software!</p>
4566: </div>
4567: </div>
4568: <div class="sect1" lang="en">
4569: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 4570: <a name="other-mandatory-files"></a>11.4. Other mandatory files</h2></div></div></div>
1.1 dsieger 4571: <div class="variablelist"><dl>
4572: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
4573: <dd><p>A multi-line description of the piece of software. This should include
4574: any credits where they are due. Please bear in mind that others do not
4575: share your sense of humour (or spelling idiosyncrasies), and that others
4576: will read everything that you write here.</p></dd>
4577: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
4578: <dd><p>This file governs the files that are installed on your
4579: system: all the binaries, manual pages, etc. There are other
4580: directives which may be entered in this file, to control the
4581: creation and deletion of directories, and the location of
1.10 hubertf 4582: inserted files. See <a class="xref" href="#plist" title="Chapter 13. PLIST issues">Chapter 13, <i>PLIST issues</i></a> for more
1.1 dsieger 4583: information.</p></dd>
4584: </dl></div>
4585: </div>
4586: <div class="sect1" lang="en">
4587: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 4588: <a name="components.optional"></a>11.5. Optional files</h2></div></div></div>
1.1 dsieger 4589: <div class="sect2" lang="en">
4590: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 4591: <a name="components.optional.bin"></a>11.5.1. Files affecting the binary package</h3></div></div></div>
1.1 dsieger 4592: <div class="variablelist"><dl>
4593: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.10 hubertf 4594: <dd><p>This shell script is invoked twice by <a class="citerefentry" 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.1 dsieger 4595: First time after package extraction and before files are
4596: moved in place, the second time after the files to install
4597: are moved in place. This can be used to do any custom
4598: procedures not possible with @exec commands in
1.10 hubertf 4599: <code class="filename">PLIST</code>. See <a class="citerefentry" 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
4600: <a class="citerefentry" 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 class="xref" href="#files-and-dirs-outside-prefix" title="15.1. Files and directories outside the installation prefix">Section 15.1, “Files and directories outside the installation prefix”</a>.</p></dd>
1.1 dsieger 4601: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
4602: <dd><p>This script is executed before and after any files are removed. It is
4603: this script's responsibility to clean up any additional messy details
4604: around the package's installation, since all pkg_delete knows is how to
4605: delete the files created in the original distribution.
1.10 hubertf 4606: See <a class="citerefentry" 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>
4607: and <a class="citerefentry" 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.1 dsieger 4608: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
4609: <dd>
4610: <p>This file is displayed after installation of the package.
4611: Useful for things like legal notices on almost-free
4612: software and hints for updating config files after
4613: installing modules for apache, PHP etc.
4614: Please note that you can modify variables in it easily by using
4615: <code class="varname">MESSAGE_SUBST</code> in the package's
4616: <code class="filename">Makefile</code>:</p>
4617: <pre class="programlisting">
4618: MESSAGE_SUBST+= SOMEVAR="somevalue"
4619: </pre>
4620: <p>replaces "${SOMEVAR}" with “<span class="quote">somevalue</span>” in
4621: <code class="filename">MESSAGE</code>. By default, substitution is
4622: performed for <code class="varname">PKGNAME</code>,
4623: <code class="varname">PKGBASE</code>, <code class="varname">PREFIX</code>,
4624: <code class="varname">LOCALBASE</code>, <code class="varname">X11PREFIX</code>,
4625: <code class="varname">X11BASE</code>,
4626: <code class="varname">PKG_SYSCONFDIR</code>,
4627: <code class="varname">ROOT_GROUP</code>, and
4628: <code class="varname">ROOT_GROUP</code>.</p>
4629: <p>You can display a different or additional files by
4630: setting the <code class="varname">MESSAGE_SRC</code> variable. Its
4631: default is <code class="filename">MESSAGE</code>, if the file
4632: exists.</p>
4633: </dd>
4634: <dt><span class="term"><code class="filename">ALTERNATIVES</code></span></dt>
4635: <dd><p>FIXME: There is no documentation on the
4636: alternatives framework.</p></dd>
4637: </dl></div>
4638: </div>
4639: <div class="sect2" lang="en">
4640: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 4641: <a name="components.optional.build"></a>11.5.2. Files affecting the build process</h3></div></div></div>
1.1 dsieger 4642: <div class="variablelist"><dl>
4643: <dt><span class="term"><code class="filename">Makefile.common</code></span></dt>
4644: <dd><p>This file contains arbitrary things that could
4645: also go into a <code class="filename">Makefile</code>, but its purpose is
4646: to be used by more than one package. This file should only be
4647: used when the packages that will use the file are known in
4648: advance. For other purposes it is often better to write a
4649: <code class="filename">*.mk</code> file and give it a good name that
4650: describes what it does.</p></dd>
4651: <dt><span class="term"><code class="filename">buildlink3.mk</code></span></dt>
4652: <dd><p>This file contains the dependency information
1.10 hubertf 4653: for the buildlink3 framework (see <a class="xref" href="#buildlink" title="Chapter 14. Buildlink methodology">Chapter 14, <i>Buildlink methodology</i></a>).</p></dd>
1.1 dsieger 4654: <dt><span class="term"><code class="filename">hacks.mk</code></span></dt>
4655: <dd><p>This file contains workarounds for compiler bugs
4656: and similar things. It is included automatically by the pkgsrc
4657: infrastructure, so you don't need an extra
4658: <code class="literal">.include</code> line for
4659: it.</p></dd>
4660: <dt><span class="term"><code class="filename">options.mk</code></span></dt>
4661: <dd><p>This file contains the code for the
1.10 hubertf 4662: package-specific options (see <a class="xref" href="#options" title="Chapter 16. Options handling">Chapter 16, <i>Options handling</i></a>) that can be
1.1 dsieger 4663: selected by the user. If a package has only one or two options,
4664: it is equally acceptable to put the code directly into the
4665: <code class="filename">Makefile</code>.</p></dd>
4666: </dl></div>
4667: </div>
4668: <div class="sect2" lang="en">
4669: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 4670: <a name="components.optional.none"></a>11.5.3. Files affecting nothing at all</h3></div></div></div>
1.1 dsieger 4671: <div class="variablelist"><dl>
4672: <dt><span class="term"><code class="filename">README*</code></span></dt>
4673: <dd><p>These files do not take place in the creation of
4674: a package and thus are purely informative to the package
4675: developer.</p></dd>
4676: <dt><span class="term"><code class="filename">TODO</code></span></dt>
4677: <dd><p>This file contains things that need to be done
4678: to make the package even
4679: better.</p></dd>
4680: </dl></div>
4681: </div>
4682: </div>
4683: <div class="sect1" lang="en">
4684: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 4685: <a name="work-dir"></a>11.6. <code class="filename">work*</code>
1.1 dsieger 4686: </h2></div></div></div>
1.10 hubertf 4687: <p>When you type <span class="command"><strong>make</strong></span>, the distribution files are
1.1 dsieger 4688: unpacked into the directory denoted by
4689: <code class="varname">WRKDIR</code>. It can be removed by running
1.10 hubertf 4690: <span class="command"><strong>make clean</strong></span>. Besides the sources, this
1.1 dsieger 4691: directory is also used to keep various timestamp files.
4692: The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
4693: The default is <code class="filename">${.CURDIR}/work</code>
4694: or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
4695: if <code class="varname">OBJMACHINE</code> is set.</p>
4696: </div>
4697: <div class="sect1" lang="en">
4698: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 4699: <a name="files-dir"></a>11.7. <code class="filename">files/*</code>
1.1 dsieger 4700: </h2></div></div></div>
4701: <p>If you have any files that you wish to be placed in the package prior
4702: to configuration or building, you could place these files here and use
1.10 hubertf 4703: a <span class="command"><strong>${CP}</strong></span> command in the
1.1 dsieger 4704: “<span class="quote">pre-configure</span>” target to achieve
4705: this. Alternatively, you could simply diff the file against
4706: <code class="filename">/dev/null</code> and use the patch mechanism to manage
4707: the creation of this file.</p>
4708: <p>If you want to share files in this way with other
4709: packages, set the <code class="varname">FILESDIR</code> variable to point
4710: to the other package's <code class="filename">files</code> directory,
4711: e.g.:</p>
4712: <pre class="programlisting">
4713: FILESDIR=${.CURDIR}/../xemacs/files
4714: </pre>
4715: </div>
4716: </div>
4717: <div class="chapter" lang="en">
4718: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 4719: <a name="makefile"></a>Chapter 12. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.1 dsieger 4720: <div class="toc">
4721: <p><b>Table of Contents</b></p>
4722: <dl>
1.6 rillig 4723: <dt><span class="sect1"><a href="#makefile.style">12.1. Caveats</a></span></dt>
4724: <dt><span class="sect1"><a href="#makefile.variables">12.2. <code class="filename">Makefile</code> variables</a></span></dt>
4725: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">12.2.1. Naming conventions</a></span></dt></dl></dd>
4726: <dt><span class="sect1"><a href="#makefile.code">12.3. Code snippets</a></span></dt>
4727: <dd><dl>
4728: <dt><span class="sect2"><a href="#adding-to-list">12.3.1. Adding things to a list</a></span></dt>
4729: <dt><span class="sect2"><a href="#converting-internal-to-external">12.3.2. Converting an internal list into an external list</a></span></dt>
4730: <dt><span class="sect2"><a href="#passing-variable-to-shell">12.3.3. Passing variables to a shell command</a></span></dt>
4731: <dt><span class="sect2"><a href="#quoting-guideline">12.3.4. Quoting guideline</a></span></dt>
4732: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">12.3.5. Workaround for a bug in BSD Make</a></span></dt>
1.1 dsieger 4733: </dl></dd>
4734: </dl>
4735: </div>
4736: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
4737: each of which forms a well-defined part of the pkgsrc system. Using
1.10 hubertf 4738: the <a class="citerefentry" 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
1.1 dsieger 4739: like pkgsrc requires some discipline to keep the code correct and
4740: understandable.</p>
4741: <p>The basic ingredients for <code class="filename">Makefile</code>
4742: programming are variables (which are actually macros) and shell
4743: commands. Among these shell commands may even be more complex ones
1.10 hubertf 4744: like <a class="citerefentry" 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
1.1 dsieger 4745: as intended it is necessary to quote all variables correctly when they
4746: are used.</p>
4747: <p>This chapter describes some patterns, that appear quite often in
4748: <code class="filename">Makefile</code>s, including the pitfalls that come along
4749: with them.</p>
4750: <div class="sect1" lang="en">
4751: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 4752: <a name="makefile.style"></a>12.1. Caveats</h2></div></div></div>
1.1 dsieger 4753: <div class="itemizedlist"><ul type="disc"><li>
4754: <p>When you are creating a file as a
4755: target of a rule, always write the data to a temporary file first
4756: and finally rename that file. Otherwise there might occur an error
4757: in the middle of generating the file, and when the user runs
1.10 hubertf 4758: <a class="citerefentry" 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 the second time, the file exists and will not be
1.1 dsieger 4759: regenerated properly. Example:</p>
4760: <pre class="programlisting">
4761: wrong:
4762: @echo "line 1" > ${.TARGET}
4763: @echo "line 2" >> ${.TARGET}
4764: @false
4765:
4766: correct:
4767: @echo "line 1" > ${.TARGET}.tmp
4768: @echo "line 2" >> ${.TARGET}.tmp
4769: @false
4770: @mv ${.TARGET}.tmp ${.TARGET}
4771: </pre>
1.10 hubertf 4772: <p>When you run <span class="command"><strong>make wrong</strong></span> twice, the file
1.1 dsieger 4773: <code class="filename">wrong</code> will exist, although there was an error
1.10 hubertf 4774: message in the first run. On the other hand, running <span class="command"><strong>make
1.1 dsieger 4775: correct</strong></span> gives an error message twice, as expected.</p>
1.10 hubertf 4776: <p>You might remember that <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> sometimes removes
1.1 dsieger 4777: <code class="literal">${.TARGET}</code> in case of error, but this only
4778: happens when it is interrupted, for example by pressing
4779: <code class="literal">^C</code>. This does <span class="emphasis"><em>not</em></span> happen
1.10 hubertf 4780: when one of the commands fails (like <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?false+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">false</span>(1)</span></a> above).</p>
1.1 dsieger 4781: </li></ul></div>
4782: </div>
4783: <div class="sect1" lang="en">
4784: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 4785: <a name="makefile.variables"></a>12.2. <code class="filename">Makefile</code> variables</h2></div></div></div>
1.1 dsieger 4786: <p><code class="filename">Makefile</code> variables contain strings that
4787: can be processed using the five operators ``='', ``+='', ``?='',
1.10 hubertf 4788: ``:='', and ``!='', which are described in the <a class="citerefentry" 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
1.1 dsieger 4789: page.</p>
4790: <p>When a variable's value is parsed from a
4791: <code class="filename">Makefile</code>, the hash character ``#'' and the
4792: backslash character ``\'' are handled specially. If a backslash is
4793: followed by a newline, any whitespace immediately in front of the
4794: backslash, the backslash, the newline, and any whitespace
4795: immediately behind the newline are replaced with a single space. A
4796: backslash character and an immediately following hash character are
4797: replaced with a single hash character. Otherwise, the backslash is
4798: passed as is. In a variable assignment, any hash character that is
4799: not preceded by a backslash starts a comment that continues upto the
4800: end of the logical line.</p>
4801: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
4802: the only way to create a variable consisting of a single backslash
4803: is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
4804: <p>So far for defining variables. The other thing you can do with
4805: variables is evaluating them. A variable is evaluated when it is
4806: part of the right side of the ``:='' or the ``!='' operator, or
4807: directly before executing a shell command which the variable is part
1.10 hubertf 4808: of. In all other cases, <a class="citerefentry" 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
1.1 dsieger 4809: is, variables are not evaluated until there's no other way. The
4810: ``modifiers'' mentioned in the man page also evaluate the
4811: variable.</p>
4812: <p>Some of the modifiers split the string into words and then
4813: operate on the words, others operate on the string as a whole. When
4814: a string is split into words, it is split as you would expect
1.10 hubertf 4815: it from <a class="citerefentry" 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.14 ! jmcneill 4816: <p>No rule without exception—the <span class="command"><strong>.for</strong></span>
1.1 dsieger 4817: loop does not follow the shell quoting rules but splits at sequences
4818: of whitespace.</p>
4819: <p>There are several types of variables that should be handled
4820: differently. Strings and two types of lists.</p>
4821: <div class="itemizedlist"><ul type="disc">
4822: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
4823: characters. Nevertheless, you should restrict yourself to only
4824: using printable characters. Examples are
4825: <code class="varname">PREFIX</code> and
4826: <code class="varname">COMMENT</code>.</p></li>
4827: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
4828: are never exported to any shell command. Their elements are
4829: separated by whitespace. Therefore, the elements themselves cannot
4830: have embedded whitespace. Any other characters are allowed.
1.10 hubertf 4831: Internal lists can be used in <span class="command"><strong>.for</strong></span> loops.
1.1 dsieger 4832: Examples are <code class="varname">DEPENDS</code> and
4833: <code class="varname">BUILD_DEPENDS</code>.</p></li>
4834: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
4835: may be exported to a shell command. Their elements can contain any
4836: characters, including whitespace. That's why they cannot be used
1.10 hubertf 4837: in <span class="command"><strong>.for</strong></span> loops. Examples are
1.1 dsieger 4838: <code class="varname">DISTFILES</code> and
4839: <code class="varname">MASTER_SITES</code>.</p></li>
4840: </ul></div>
4841: <div class="sect2" lang="en">
4842: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 4843: <a name="makefile.variables.names"></a>12.2.1. Naming conventions</h3></div></div></div>
1.1 dsieger 4844: <div class="itemizedlist"><ul type="disc">
4845: <li><p>All variable names starting with an underscore
4846: are reserved for use by the pkgsrc infrastructure. They shall
4847: not be used by package
4848: <code class="filename">Makefile</code>s.</p></li>
1.10 hubertf 4849: <li><p>In <span class="command"><strong>.for</strong></span> loops you should use
1.1 dsieger 4850: lowercase variable names for the iteration
4851: variables.</p></li>
4852: <li><p>All list variables should have a ``plural''
4853: name, e.g. <code class="varname">PKG_OPTIONS</code> or
4854: <code class="varname">DISTFILES</code>.</p></li>
4855: </ul></div>
4856: </div>
4857: </div>
4858: <div class="sect1" lang="en">
4859: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 4860: <a name="makefile.code"></a>12.3. Code snippets</h2></div></div></div>
1.1 dsieger 4861: <p>This section presents you with some code snippets you should
4862: use in your own code. If you don't find anything appropriate here,
4863: you should test your code and add it here.</p>
4864: <div class="sect2" lang="en">
4865: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 4866: <a name="adding-to-list"></a>12.3.1. Adding things to a list</h3></div></div></div>
1.1 dsieger 4867: <pre class="programlisting">
4868: STRING= foo * bar `date`
4869: INT_LIST= # empty
4870: ANOTHER_INT_LIST= apache-[0-9]*:../../www/apache
4871: EXT_LIST= # empty
4872: ANOTHER_EXT_LIST= a=b c=d
4873:
4874: INT_LIST+= ${STRING} # 1
4875: INT_LIST+= ${ANOTHER_INT_LIST} # 2
4876: EXT_LIST+= ${STRING:Q} # 3
4877: EXT_LIST+= ${ANOTHER_EXT_LIST} # 4
4878: </pre>
4879: <p>When you add a string to an external list (example 3), it
4880: must be quoted. In all other cases, you must not add a quoting
4881: level. You must not merge internal and external lists, unless you
4882: are sure that all entries are correctly interpreted in both
4883: lists.</p>
4884: </div>
4885: <div class="sect2" lang="en">
4886: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 4887: <a name="converting-internal-to-external"></a>12.3.2. Converting an internal list into an external list</h3></div></div></div>
1.1 dsieger 4888: <pre class="programlisting">
4889: EXT_LIST= # empty
4890: .for i in ${INT_LIST}
4891: EXT_LIST+= ${i:Q}""
4892: .endfor
4893: </pre>
4894: <p>This code converts the internal list
4895: <code class="varname">INT_LIST</code> into the external list
4896: <code class="varname">EXT_LIST</code>. As the elements of an internal list
4897: are unquoted they must be quoted here. The reason for appending
4898: <code class="varname">""</code> is explained below.</p>
4899: </div>
4900: <div class="sect2" lang="en">
4901: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 4902: <a name="passing-variable-to-shell"></a>12.3.3. Passing variables to a shell command</h3></div></div></div>
1.1 dsieger 4903: <p>Sometimes you may want to print an arbitrary string. There
4904: are many ways to get it wrong and only few that can handle every
4905: nastiness.</p>
4906: <pre class="programlisting">
4907: STRING= foo bar < > * `date` $$HOME ' "
4908: EXT_LIST= string=${STRING:Q} x=second\ item
4909:
4910: all:
4911: echo ${STRING} # 1
4912: echo "${STRING}" # 2
4913: echo "${STRING:Q}" # 3
4914: echo ${STRING:Q} # 4
4915: echo x${STRING:Q} | sed 1s,.,, # 5
4916: printf "%s\\n" ${STRING:Q}"" # 6
4917: env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
4918: </pre>
4919: <p>Example 1 leads to a syntax error in the shell, as the
4920: characters are just copied.</p>
4921: <p>Example 2 leads to a syntax error too, and if you leave out
4922: the last " character from <code class="varname">${STRING}</code>,
1.10 hubertf 4923: <a class="citerefentry" 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
1.1 dsieger 4924: variable would be evaluated, too.</p>
4925: <p>Example 3 outputs each space character preceded by a
4926: backslash (or not), depending on the implementation of the
1.10 hubertf 4927: <a class="citerefentry" 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>
1.1 dsieger 4928: <p>Example 4 handles correctly every string that does not start
4929: with a dash. In that case, the result depends on the
1.10 hubertf 4930: implementation of the <a class="citerefentry" 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
1.1 dsieger 4931: guarantee that your input does not start with a dash, this form is
4932: appropriate.</p>
4933: <p>Example 5 handles even the case of a leading dash
4934: correctly.</p>
4935: <p>Example 6 also works with every string and is the
4936: light-weight solution, since it does not involve a pipe, which has
4937: its own problems.</p>
4938: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
4939: because the quoting has already been done when adding elements to
4940: the list.</p>
4941: <p>As internal lists shall not be passed to the shell, there is
4942: no example for it.</p>
4943: </div>
4944: <div class="sect2" lang="en">
4945: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 4946: <a name="quoting-guideline"></a>12.3.4. Quoting guideline</h3></div></div></div>
1.1 dsieger 4947: <p>There are many possible sources of wrongly quoted variables.
4948: This section lists some of the commonly known ones.</p>
4949: <div class="itemizedlist"><ul type="disc">
4950: <li>
4951: <p>Whenever you use the value of a list, think
4952: about what happens to leading or trailing whitespace. If the
4953: list is a well-formed shell expression, you can apply the
4954: <code class="varname">:M*</code> modifier to strip leading and trailing
4955: whitespace from each word. The <code class="varname">:M</code> operator
4956: first splits its argument according to the rules of the shell,
4957: and then creates a new list consisting of all words that match
4958: the shell glob expression <code class="varname">*</code>, that is: all.
4959: One class of situations where this is needed is when adding a
4960: variable like <code class="varname">CPPFLAGS</code> to
4961: <code class="varname">CONFIGURE_ARGS</code>. If the configure script
4962: invokes other configure scripts, it strips the leading and
4963: trailing whitespace from the variable and then passes it to the
4964: other configure scripts. But these configure scripts expect the
4965: (child) <code class="varname">CPPFLAGS</code> variable to be the same as
4966: the parent <code class="varname">CPPFLAGS</code>. That's why we better
4967: pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
4968: here is how we do it:</p>
4969: <pre class="programlisting">
4970: CPPFLAGS= # empty
4971: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX:Q}\"
4972: CPPFLAGS+= ${MY_CPPFLAGS}
4973:
4974: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
4975:
4976: all:
4977: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
4978: echo x${CONFIGURE_ARGS}x # properly trimmed
4979: </pre>
4980: </li>
4981: <li><p>The example above contains one bug: The
4982: <code class="varname">${PREFIX}</code> is a properly quoted shell
4983: expression, but there is the C compiler after it, which also
4984: expects a properly quoted string (this time in C syntax). The
4985: version above is therefore only correct if
4986: <code class="varname">${PREFIX}</code> does not have embedded backslashes
4987: or double quotes. If you want to allow these, you have to add
4988: another layer of quoting to each variable that is used as a C
4989: string literal. You cannot use the <code class="varname">:Q</code>
4990: operator for it, as this operator only works for the
4991: shell.</p></li>
4992: <li>
4993: <p>Whenever a variable can be empty, the
4994: <code class="varname">:Q</code> operator can have surprising results. Here
4995: are two completely different cases which can be solved with the
4996: same trick.</p>
4997: <pre class="programlisting">
4998: EMPTY= # empty
4999: empty_test:
5000: for i in a ${EMPTY:Q} c; do \
5001: echo "$$i"; \
5002: done
5003:
5004: for_test:
5005: .for i in a:\ a:\test.txt
5006: echo ${i:Q}
5007: echo "foo"
5008: .endfor
5009: </pre>
5010: <p>The first example will only print two of the three lines
5011: we might have expected. This is because
5012: <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
5013: the shell cannot see. The workaround is to write
5014: <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
5015: as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
5016: -f ${FNAME:Q}</code> (both of these are wrong).</p>
5017: <p>The second example will only print three lines instead of
5018: four. The first line looks like <code class="varname">a:\ echo foo</code>.
5019: This is because the backslash of the value
5020: <code class="varname">a:\</code> is interpreted as a line-continuation by
1.10 hubertf 5021: <a class="citerefentry" 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
5022: <a class="citerefentry" 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
1.1 dsieger 5023: <code class="varname">${i:Q}""</code>.</p>
5024: </li>
5025: </ul></div>
5026: </div>
5027: <div class="sect2" lang="en">
5028: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 5029: <a name="bsd-make-bug-workaround"></a>12.3.5. Workaround for a bug in BSD Make</h3></div></div></div>
1.1 dsieger 5030: <p>The pkgsrc bmake program does not handle the following
5031: assignment correctly. In case <code class="varname">_othervar_</code>
5032: contains a ``-'' character, one of the closing braces is included
5033: in <code class="varname">${VAR}</code> after this code executes.</p>
5034: <pre class="programlisting">
5035: VAR:= ${VAR:N${_othervar_:C/-//}}
5036: </pre>
5037: <p>For a more complex code snippet and a workaround, see the
5038: package <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/regress/make-quoting/README.html" target="_top"><code class="filename">regress/make-quoting</code></a>, testcase
5039: <code class="varname">bug1</code>.</p>
5040: </div>
5041: </div>
5042: </div>
5043: <div class="chapter" lang="en">
5044: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 5045: <a name="plist"></a>Chapter 13. PLIST issues</h2></div></div></div>
1.1 dsieger 5046: <div class="toc">
5047: <p><b>Table of Contents</b></p>
5048: <dl>
1.6 rillig 5049: <dt><span class="sect1"><a href="#rcs-id">13.1. RCS ID</a></span></dt>
5050: <dt><span class="sect1"><a href="#automatic-plist-generation">13.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
1.10 hubertf 5051: <dt><span class="sect1"><a href="#print-PLIST">13.3. Tweaking output of <span class="command"><strong>make print-PLIST</strong></span></a></span></dt>
1.6 rillig 5052: <dt><span class="sect1"><a href="#plist.misc">13.4. Variable substitution in PLIST</a></span></dt>
5053: <dt><span class="sect1"><a href="#manpage-compression">13.5. Man page compression</a></span></dt>
5054: <dt><span class="sect1"><a href="#using-PLIST_SRC">13.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
5055: <dt><span class="sect1"><a href="#platform-specific-plist">13.7. Platform-specific and differing PLISTs</a></span></dt>
5056: <dt><span class="sect1"><a href="#faq.common-dirs">13.8. Sharing directories between packages</a></span></dt>
1.1 dsieger 5057: </dl>
5058: </div>
5059: <p>The <code class="filename">PLIST</code> file contains a package's
5060: “<span class="quote">packing list</span>”, i.e. a list of files that belong to
5061: the package (relative to the <code class="filename">${PREFIX}</code>
5062: directory it's been installed in) plus some additional statements
1.10 hubertf 5063: - see the <a class="citerefentry" 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.
1.1 dsieger 5064: This chapter addresses some issues that need attention when
5065: dealing with the <code class="filename">PLIST</code> file (or files, see
5066: below!).</p>
5067: <div class="sect1" lang="en">
5068: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 5069: <a name="rcs-id"></a>13.1. RCS ID</h2></div></div></div>
1.1 dsieger 5070: <p>Be sure to add a RCS ID line as the first thing in any
5071: <code class="filename">PLIST</code> file you write:</p>
5072: <pre class="programlisting">
5073: @comment $NetBSD$
5074: </pre>
5075: </div>
5076: <div class="sect1" lang="en">
5077: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 5078: <a name="automatic-plist-generation"></a>13.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.10 hubertf 5079: <p>You can use the <span class="command"><strong>make print-PLIST</strong></span> command
1.1 dsieger 5080: to output a PLIST that matches any new files since the package
1.10 hubertf 5081: was extracted. See <a class="xref" href="#build.helpful-targets" title="17.17. Other helpful targets">Section 17.17, “Other helpful targets”</a> for
1.1 dsieger 5082: more information on this target.</p>
5083: </div>
5084: <div class="sect1" lang="en">
5085: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.10 hubertf 5086: <a name="print-PLIST"></a>13.3. Tweaking output of <span class="command"><strong>make print-PLIST</strong></span>
1.1 dsieger 5087: </h2></div></div></div>
5088: <p>If you have used any of the *-dirs packages, as explained in
1.10 hubertf 5089: <a class="xref" href="#faq.common-dirs" title="13.8. Sharing directories between packages">Section 13.8, “Sharing directories between packages”</a>, you may have noticed that
5090: <span class="command"><strong>make print-PLIST</strong></span> outputs a set of
1.1 dsieger 5091: <code class="varname">@comment</code>s instead of real
5092: <code class="varname">@dirrm</code> lines. You can also do this for
5093: specific directories and files, so that the results of that
5094: command are very close to reality. This helps <span class="emphasis"><em>a
5095: lot</em></span> during the update of packages.</p>
5096: <p>The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
5097: of AWK patterns and actions that are used to filter the output of
5098: print-PLIST. You can <span class="emphasis"><em>append</em></span> any chunk of AWK
5099: scripting you like to it, but be careful with quoting.</p>
5100: <p>For example, to get all files inside the
5101: <code class="filename">libdata/foo</code> directory removed from the
5102: resulting PLIST:</p>
5103: <pre class="programlisting">
5104: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
5105: </pre>
5106: <p>And to get all the <code class="varname">@dirrm</code> lines referring
5107: to a specific (shared) directory converted to
5108: <code class="varname">@comment</code>s:</p>
5109: <pre class="programlisting">
5110: PRINT_PLIST_AWK+= /^@dirrm share\/specific/ { print "@comment " $$0; next; }
5111: </pre>
5112: </div>
5113: <div class="sect1" lang="en">
5114: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 5115: <a name="plist.misc"></a>13.4. Variable substitution in PLIST</h2></div></div></div>
1.1 dsieger 5116: <p>A number of variables are substituted automatically in
5117: PLISTs when a package is installed on a system. This includes the
5118: following variables:</p>
5119: <div class="variablelist"><dl>
5120: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
5121: <dd>
5122: <p>Some packages like emacs and perl embed information
5123: about which architecture they were built on into the
5124: pathnames where they install their files. To handle this
5125: case, PLIST will be preprocessed before actually used, and
5126: the symbol
5127: “<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>” will be
1.10 hubertf 5128: replaced by what <span class="command"><strong>uname -p</strong></span> gives. The
1.1 dsieger 5129: same is done if the string
5130: <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
5131: PLIST somewhere - use this on packages that have GNU
5132: autoconf-created configure scripts.</p>
5133: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
5134: <h3 class="title">Legacy note</h3>
5135: <p>There used to be a symbol
5136: “<span class="quote"><code class="varname">$ARCH</code></span>” that
1.10 hubertf 5137: was replaced by the output of <span class="command"><strong>uname
1.1 dsieger 5138: -m</strong></span>, but that's no longer supported and has
5139: been removed.</p>
5140: </div>
5141: </dd>
5142: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
5143: <dd>
5144: <p>Some packages want to embed the OS name and version
5145: into some paths. To do this, use these variables in the
5146: <code class="filename">PLIST</code>:
5147: </p>
5148: <div class="itemizedlist"><ul type="disc">
1.10 hubertf 5149: <li><p><code class="varname">${OPSYS}</code> - output of “<span class="quote"><span class="command"><strong>uname -s</strong></span></span>”</p></li>
1.1 dsieger 5150: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. “<span class="quote">solaris</span>”)</p></li>
1.10 hubertf 5151: <li><p><code class="varname">${OS_VERSION}</code> - “<span class="quote"><span class="command"><strong>uname -r</strong></span></span>”</p></li>
1.1 dsieger 5152: </ul></div>
5153: </dd>
5154: </dl></div>
5155: <p>For a complete list of values which are replaced by
5156: default, please look in <code class="filename">bsd.pkg.mk</code> (and
5157: search for <code class="varname">PLIST_SUBST</code>).</p>
5158: <p>If you want to change other variables not listed above, you
5159: can add variables and their expansions to this variable in the
1.10 hubertf 5160: following way, similar to <code class="varname">MESSAGE_SUBST</code> (see <a class="xref" href="#components.optional" title="11.5. Optional files">Section 11.5, “Optional files”</a>):</p>
1.1 dsieger 5161: <pre class="programlisting">
5162: PLIST_SUBST+= SOMEVAR="somevalue"
5163: </pre>
5164: <p>This replaces all occurrences of “<span class="quote">${SOMEVAR}</span>”
5165: in the <code class="filename">PLIST</code> with
5166: “<span class="quote">somevalue</span>”.</p>
5167: </div>
5168: <div class="sect1" lang="en">
5169: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 5170: <a name="manpage-compression"></a>13.5. Man page compression</h2></div></div></div>
1.1 dsieger 5171: <p>Man pages should be installed in compressed form if
5172: <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
5173: and uncompressed otherwise. To handle this in the
5174: <code class="filename">PLIST</code> file, the suffix “<span class="quote">.gz</span>” is
5175: appended/removed automatically for man pages according to
5176: <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
5177: or not, see above for details. This modification of the
5178: <code class="filename">PLIST</code> file is done on a copy of it, not
5179: <code class="filename">PLIST</code> itself.</p>
5180: </div>
5181: <div class="sect1" lang="en">
5182: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 5183: <a name="using-PLIST_SRC"></a>13.6. Changing PLIST source with <code class="varname">PLIST_SRC</code>
1.1 dsieger 5184: </h2></div></div></div>
5185: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
5186: in generating the binary package, set the variable
5187: <code class="varname">PLIST_SRC</code> to the names of that file(s).
1.10 hubertf 5188: The files are later concatenated using <a class="citerefentry" 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
1.1 dsieger 5189: important. The default for <code class="varname">PLIST_SRC</code> is
5190: <code class="filename">${PKGDIR}/PLIST</code>.</p>
5191: </div>
5192: <div class="sect1" lang="en">
5193: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 5194: <a name="platform-specific-plist"></a>13.7. Platform-specific and differing PLISTs</h2></div></div></div>
1.1 dsieger 5195: <p>Some packages decide to install a different set of files based on
5196: the operating system being used. These differences can be
5197: automatically handled by using the following files:</p>
5198: <div class="itemizedlist"><ul type="disc">
5199: <li><p><code class="filename">PLIST.common</code></p></li>
5200: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
5201: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
5202: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
5203: <li><p><code class="filename">PLIST.common_end</code></p></li>
5204: </ul></div>
5205: </div>
5206: <div class="sect1" lang="en">
5207: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 5208: <a name="faq.common-dirs"></a>13.8. Sharing directories between packages</h2></div></div></div>
1.1 dsieger 5209: <p>A “<span class="quote">shared directory</span>” is a directory where
5210: multiple (and unrelated) packages install files. These
5211: directories are problematic because you have to add special tricks
5212: in the PLIST to conditionally remove them, or have some
5213: centralized package handle them.</p>
5214: <p>Within pkgsrc, you'll find both approaches. If a directory
5215: is shared by a few unrelated packages, it's often not worth to add
5216: an extra package to remove it. Therefore, one simply does:</p>
5217: <pre class="programlisting">
5218: @unexec ${RMDIR} %D/path/to/shared/directory 2>/dev/null || ${TRUE}
5219: </pre>
5220: <p>in the PLISTs of all affected packages, instead of the
5221: regular "@dirrm" line.</p>
5222: <p>However, if the directory is shared across many packages, two
5223: different solutions are available:</p>
5224: <div class="orderedlist"><ol type="1">
5225: <li><p>If the packages have a common dependency, the directory
5226: can be removed in that. For example, see
5227: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/textproc/scrollkeeper/README.html" target="_top"><code class="filename">textproc/scrollkeeper</code></a>, which
5228: removes the shared directory
5229: <code class="filename">share/omf</code>.</p></li>
5230: <li><p>If the packages using the directory are not related at
5231: all (they have no common dependencies), a *-dirs package is
5232: used.</p></li>
5233: </ol></div>
5234: <p>From now on, we'll discuss the second solution. To get an
5235: idea of the *-dirs packages available, issue:</p>
5236: <pre class="programlisting">
5237: <code class="prompt">%</code> cd .../pkgsrc
5238: <code class="prompt">%</code> ls -d */*-dirs
5239: </pre>
5240: <p>Their use from other packages is very simple. The
5241: <code class="varname">USE_DIRS</code> variable takes a list of package names
5242: (without the “<span class="quote">-dirs</span>” part) together with the required
5243: version number (always pick the latest one when writing new
5244: packages).</p>
5245: <p>For example, if a package installs files under
5246: <code class="filename">share/applications</code>, it should have the
5247: following line in it:</p>
5248: <pre class="programlisting">
5249: USE_DIRS+= xdg-1.1
5250: </pre>
1.10 hubertf 5251: <p>After regenerating the PLIST using <span class="command"><strong>make
1.1 dsieger 5252: print-PLIST</strong></span>, you should get the right (commented out)
5253: lines.</p>
5254: <p>Note that even if your package is using
5255: <code class="filename">$X11BASE</code>, it must not depend on the
5256: *-x11-dirs packages. Just specify the name without that part and
5257: pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
5258: care of it.</p>
5259: </div>
5260: </div>
5261: <div class="chapter" lang="en">
5262: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 5263: <a name="buildlink"></a>Chapter 14. Buildlink methodology</h2></div></div></div>
1.1 dsieger 5264: <div class="toc">
5265: <p><b>Table of Contents</b></p>
5266: <dl>
1.6 rillig 5267: <dt><span class="sect1"><a href="#converting-to-buildlink3">14.1. Converting packages to use buildlink3</a></span></dt>
5268: <dt><span class="sect1"><a href="#creating-buildlink3.mk">14.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
1.1 dsieger 5269: <dd><dl>
1.6 rillig 5270: <dt><span class="sect2"><a href="#anatomy-of-bl3">14.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
5271: <dt><span class="sect2"><a href="#updating-buildlink-depends">14.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.1 dsieger 5272: </dl></dd>
1.6 rillig 5273: <dt><span class="sect1"><a href="#writing-builtin.mk">14.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
1.1 dsieger 5274: <dd><dl>
1.6 rillig 5275: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">14.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
5276: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">14.3.2. Global preferences for native or pkgsrc software</a></span></dt>
1.1 dsieger 5277: </dl></dd>
5278: </dl>
5279: </div>
5280: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
5281: are seen by a package's configure and build processes. This is implemented
5282: in a two step process:</p>
5283: <div class="orderedlist"><ol type="1">
5284: <li><p>Symlink headers and libraries for dependencies into
5285: <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
5286: of <code class="varname">WRKDIR</code>.</p></li>
5287: <li><p>Create wrapper scripts that are used in place of the normal compiler
5288: tools that translate <code class="option">-I${LOCALBASE}/include</code> and
5289: <code class="option">-L${LOCALBASE}/lib</code> into references to
5290: <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
5291: native compiler on some operating systems look like GCC, so that
5292: packages that expect GCC won't require modifications to build with
5293: those native compilers.</p></li>
5294: </ol></div>
5295: <p>This normalizes the environment in which a package is built so that the
5296: package may be built consistently despite what other software may be
5297: installed. Please note that the normal system header and library paths,
5298: e.g. <code class="filename">/usr/include</code>,
5299: <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
5300: designed to insulate the package build from non-system-supplied
5301: software.</p>
5302: <div class="sect1" lang="en">
5303: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 5304: <a name="converting-to-buildlink3"></a>14.1. Converting packages to use buildlink3</h2></div></div></div>
1.1 dsieger 5305: <p>The process of converting packages to use the buildlink3
5306: framework (“<span class="quote">bl3ifying</span>”) is fairly straightforward.
5307: The things to keep in mind are:</p>
5308: <div class="orderedlist"><ol type="1">
5309: <li><p>Ensure that the build always calls the wrapper scripts
5310: instead of the actual toolchain. Some packages are tricky,
5311: and the only way to know for sure is the check
5312: <code class="filename">${WRKDIR}/.work.log</code> to see if the
5313: wrappers are being invoked.</p></li>
5314: <li><p>Don't override <code class="varname">PREFIX</code> from within
5315: the package Makefile, e.g. Java VMs, standalone shells,
5316: etc., because the code to symlink files into
5317: <code class="filename">${BUILDLINK_DIR}</code> looks for files
5318: relative to “<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>”.
5319: </p></li>
5320: <li><p>Remember that <span class="emphasis"><em>only</em></span> the
5321: <code class="filename">buildlink3.mk</code> files that you list in a
5322: package's Makefile are added as dependencies for that package.
5323: </p></li>
5324: </ol></div>
5325: <p>If a dependency on a particular package is required for its libraries and
5326: headers, then we replace:</p>
5327: <pre class="programlisting">
5328: DEPENDS+= foo>=1.1.0:../../category/foo
5329: </pre>
5330: <p>with</p>
5331: <pre class="programlisting">
5332: .include "../../category/foo/buildlink3.mk"
5333: </pre>
5334: <p>The buildlink3.mk files usually define the required dependencies.
5335: If you need a newer version of the dependency when using buildlink3.mk
5336: files, then you can define it in your Makefile; for example:</p>
5337: <pre class="programlisting">
5338: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
5339: .include "../../category/foo/buildlink3.mk"
5340: </pre>
5341: <p>There are several <code class="filename">buildlink3.mk</code>
5342: files in <code class="filename">pkgsrc/mk</code>
5343: that handle special package issues:</p>
5344: <div class="itemizedlist"><ul type="disc">
5345: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
5346: the native or a pkgsrc Berkeley DB implementation based on
5347: the values of <code class="varname">BDB_ACCEPTED</code> and
5348: <code class="varname">BDB_DEFAULT</code>.</p></li>
5349: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
5350: comes with neither Curses nor NCurses, this will take care
5351: to install the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/ncurses/README.html" target="_top"><code class="filename">devel/ncurses</code></a> package.</p></li>
5352: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
5353: of <code class="varname">KRB5_ACCEPTED</code> to choose between
5354: adding a dependency on Heimdal or MIT-krb5 for packages that
5355: require a Kerberos 5 implementation.</p></li>
5356: <li><p><code class="filename">motif.buildlink3.mk</code> checks for a
5357: system-provided Motif installation or adds a dependency on
5358: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/lesstif/README.html" target="_top"><code class="filename">x11/lesstif</code></a> or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/openmotif/README.html" target="_top"><code class="filename">x11/openmotif</code></a>. The user can set
5359: <code class="varname">MOTIF_TYPE</code> to “<span class="quote">dt</span>”,
5360: “<span class="quote">lesstif</span>”, or “<span class="quote">openmotif</span>” to choose
5361: which Motif version will be used.</p></li>
5362: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
5363: variables that may be used by packages that use the
5364: Open Sound System (OSS) API.</p></li>
5365: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
5366: either Postgres 8.0, 8.1, or 8.2, whichever is found installed. See
5367: the file for more information.</p></li>
5368: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
5369: <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
5370: a dependency on <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/pth/README.html" target="_top"><code class="filename">devel/pth</code></a> as needed.</p></li>
5371: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
5372: <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
5373: library.</p></li>
5374: </ul></div>
5375: <p>The comments in those <code class="filename">buildlink3.mk</code>
5376: files provide a more complete
5377: description of how to use them properly.</p>
5378: </div>
5379: <div class="sect1" lang="en">
5380: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 5381: <a name="creating-buildlink3.mk"></a>14.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
1.7 rillig 5382: <a name="buildlink3.mk"></a><p>A package's <code class="filename">buildlink3.mk</code> file is
1.1 dsieger 5383: included by Makefiles to indicate the need to compile and link
5384: against header files and libraries provided by the package. A
5385: <code class="filename">buildlink3.mk</code> file should always provide
5386: enough information to add the correct type of dependency
5387: relationship and include any other
5388: <code class="filename">buildlink3.mk</code> files that it needs to find
5389: headers and libraries that it needs in turn.</p>
5390: <p>To generate an initial <code class="filename">buildlink3.mk</code>
5391: file for further editing, Rene Hexel's <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/createbuildlink/README.html" target="_top"><code class="filename">pkgtools/createbuildlink</code></a>
5392: package is highly recommended. For most packages, the following
5393: command will generate a good starting point for
5394: <code class="filename">buildlink3.mk</code> files:</p>
5395: <pre class="screen">
5396: <code class="prompt">%</code> <strong class="userinput"><code>cd pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>pkgdir</code></em>
5397: <code class="prompt">%</code> createbuildlink >buildlink3.mk</code></strong>
5398: </pre>
5399: <div class="sect2" lang="en">
5400: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 5401: <a name="anatomy-of-bl3"></a>14.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
1.1 dsieger 5402: <p>The following real-life example
5403: <code class="filename">buildlink3.mk</code> is taken
5404: from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
5405: <pre class="programlisting">
5406: # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
5407:
5408: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
5409: TIFF_BUILDLINK3_MK:= ${TIFF_BUILDLINK3_MK}+
5410:
5411: .if ${BUILDLINK_DEPTH} == "+"
5412: BUILDLINK_DEPENDS+= tiff
5413: .endif
5414:
5415: BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Ntiff}
5416: BUILDLINK_PACKAGES+= tiff
5417:
5418: .if ${TIFF_BUILDLINK3_MK} == "+"
5419: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
5420: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
5421: .endif # TIFF_BUILDLINK3_MK
5422:
5423: .include "../../devel/zlib/buildlink3.mk"
5424: .include "../../graphics/jpeg/buildlink3.mk"
5425:
5426: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
5427: </pre>
5428: <p>The header and footer manipulate
5429: <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
5430: <code class="filename">buildlink3.mk</code> files and is used to track
5431: at what depth we are including
5432: <code class="filename">buildlink3.mk</code> files.</p>
5433: <p>The first section controls if the dependency on
5434: <em class="replaceable"><code>pkg</code></em> is added.
5435: <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
5436: packages for which dependencies are added by
5437: buildlink3.</p>
5438: <p>The second section advises pkgsrc that the
5439: <code class="filename">buildlink3.mk</code> file for
5440: <em class="replaceable"><code>pkg</code></em> has been included at some point.
5441: <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
5442: packages for which <code class="filename">buildlink3.mk</code> files
5443: have been included. It must <span class="emphasis"><em>always</em></span> be
5444: appended to within a <code class="filename">buildlink3.mk</code>
5445: file.</p>
5446: <p>The third section is protected from multiple inclusion
5447: and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
5448: added. Several important variables are set in the section:</p>
5449: <div class="itemizedlist"><ul type="disc">
5450: <li><p><code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5451: is the actual dependency recorded in the installed
5452: package; this should always be set using
1.10 hubertf 5453: <span class="command"><strong>+=</strong></span> to ensure that
1.1 dsieger 5454: we're appending to any pre-existing list of values. This
5455: variable should be set to the first version of the
5456: package that had an API change.
5457: </p></li>
5458: <li><p><code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
5459: is the location of the <em class="replaceable"><code>pkg</code></em>
5460: pkgsrc directory.</p></li>
5461: <li><p><code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
5462: (not shown above) controls whether we use
5463: <code class="varname">BUILD_DEPENDS</code> or
5464: <code class="varname">DEPENDS</code> to add the dependency on
5465: <em class="replaceable"><code>pkg</code></em>. The build dependency is
5466: selected by setting
5467: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
5468: to “<span class="quote">build</span>”. By default, the full dependency is
5469: used.</p></li>
5470: <li><p><code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
5471: and
5472: <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
5473: (not shown above) are lists of subdirectories of
5474: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
5475: to add to the header and library search paths. These
5476: default to “<span class="quote">include</span>” and “<span class="quote">lib</span>”
5477: respectively.</p></li>
5478: <li><p><code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
5479: (not shown above) is the list of preprocessor flags to add
5480: to <code class="varname">CPPFLAGS</code>, which are passed on to the
5481: configure and build phases. The “<span class="quote">-I</span>” option
5482: should be avoided and instead be handled using
5483: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
5484: above.</p></li>
5485: </ul></div>
5486: <p>The following variables are all optionally defined within
5487: this second section (protected against multiple inclusion) and
5488: control which package files are symlinked into
5489: <code class="filename">${BUILDLINK_DIR}</code> and how their names are
5490: transformed during the symlinking:</p>
5491: <div class="itemizedlist"><ul type="disc">
5492: <li><p><code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
5493: (not shown above) is a shell glob pattern relative to
5494: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
5495: to be symlinked into
5496: <code class="filename">${BUILDLINK_DIR}</code>,
5497: e.g. <code class="filename">include/*.h</code>.</p></li>
5498: <li><p><code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
5499: (not shown above) is a shell pipeline that
5500: outputs to stdout a list of files relative to
5501: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
5502: The resulting files are to be symlinked
5503: into <code class="filename">${BUILDLINK_DIR}</code>. By default,
5504: this takes the <code class="filename">+CONTENTS</code> of a
5505: <em class="replaceable"><code>pkg</code></em> and filters it through
5506: <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.</p></li>
5507: <li><p><code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
5508: (not shown above) is a filter command that filters
5509: <code class="filename">+CONTENTS</code> input into a list of files
5510: relative to
5511: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
5512: on stdout. By default for overwrite packages,
5513: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
5514: outputs the contents of the <code class="filename">include</code>
5515: and <code class="filename">lib</code> directories in the package
5516: <code class="filename">+CONTENTS</code>, and for pkgviews packages,
5517: it outputs any libtool archives in
5518: <code class="filename">lib</code> directories.</p></li>
5519: <li><p><code class="varname">BUILDLINK_FNAME_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
5520: (not shown above) is a list of sed arguments used to
5521: transform the name of the source filename into a
1.10 hubertf 5522: destination filename, e.g. <span class="command"><strong>-e
1.1 dsieger 5523: "s|/curses.h|/ncurses.h|g"</strong></span>.</p></li>
5524: </ul></div>
5525: <p>The last section includes any
5526: <code class="filename">buildlink3.mk</code> needed for
5527: <em class="replaceable"><code>pkg</code></em>'s library dependencies.
5528: Including these <code class="filename">buildlink3.mk</code> files
5529: means that the headers and libraries for these
5530: dependencies are also symlinked into
5531: <code class="filename">${BUILDLINK_DIR}</code>
5532: whenever the <em class="replaceable"><code>pkg</code></em>
5533: <code class="filename">buildlink3.mk</code>
5534: file is included.</p>
5535: </div>
5536: <div class="sect2" lang="en">
5537: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 5538: <a name="updating-buildlink-depends"></a>14.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.1 dsieger 5539: <p>The situation that requires increasing the dependency listed in
5540: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5541: after a package update is when the API or interface to the
5542: header files change.</p>
5543: <p>In this case,
5544: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5545: should be adjusted to require at least the new package
5546: version. In some cases, the packages that depend on this new
5547: version may need their <code class="varname">PKGREVISION</code>s
5548: increased and, if they have <code class="filename">buildlink3.mk</code>
5549: files, their
5550: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5551: adjusted, too. This is needed so pkgsrc will require the
5552: correct package dependency and not settle for an older one
5553: when building the source.</p>
5554: <p><code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5555: should be increased when the binary interface or sonames
5556: (major number of the library version) of any installed
5557: shared libraries change. This is needed so that binary
5558: packages made using it will require the correct package
5559: dependency and not settle for an older one which will not
5560: contain the necessary shared libraries.</p>
1.10 hubertf 5561: <p>See <a class="xref" href="#dependencies" title="19.1.6. Handling dependencies">Section 19.1.6, “Handling dependencies”</a> for
1.1 dsieger 5562: more information about dependencies on other packages,
5563: including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
5564: <code class="varname">ABI_DEPENDS</code> definitions.</p>
5565: <p>Please take careful consideration before adjusting
5566: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5567: or
5568: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5569: as we don't want to cause unneeded package deletions and
5570: rebuilds. In many cases, new versions of packages work just
5571: fine with older dependencies.</p>
5572: <p>Also it is not needed to set
5573: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5574: when it is identical to
5575: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>. </p>
5576: </div>
5577: </div>
5578: <div class="sect1" lang="en">
5579: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 5580: <a name="writing-builtin.mk"></a>14.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.1 dsieger 5581: <p>Some packages in pkgsrc install headers and libraries that
5582: coincide with headers and libraries present in the base system.
5583: Aside from a <code class="filename">buildlink3.mk</code> file, these
5584: packages should also include a <code class="filename">builtin.mk</code>
5585: file that includes the necessary checks to decide whether using
5586: the built-in software or the pkgsrc software is
5587: appropriate.</p>
5588: <p>The only requirements of a builtin.mk file for
5589: <em class="replaceable"><code>pkg</code></em> are:</p>
5590: <div class="orderedlist"><ol type="1">
5591: <li><p>It should set
5592: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5593: to either “<span class="quote">yes</span>” or “<span class="quote">no</span>”
5594: after it is included.</p></li>
5595: <li><p>It should <span class="emphasis"><em>not</em></span> override any
5596: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5597: which is already set before the
5598: <code class="filename">builtin.mk</code> file is included.</p></li>
5599: <li><p>It should be written to allow multiple inclusion. This
5600: is <span class="emphasis"><em>very</em></span> important and takes careful
5601: attention to <code class="filename">Makefile</code> coding.</p></li>
5602: </ol></div>
5603: <div class="sect2" lang="en">
5604: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 5605: <a name="anatomy-of-builtin.mk"></a>14.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</h3></div></div></div>
1.1 dsieger 5606: <p>The following is the recommended template for builtin.mk
5607: files:</p>
5608: <pre class="programlisting">
5609: .if !defined(IS_BUILTIN.foo)
5610: #
5611: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
5612: # genuinely exists in the system or not.
5613: #
5614: IS_BUILTIN.foo?= no
5615:
5616: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
5617: # version can be determined.
5618: #
5619: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
5620: BUILTIN_PKG.foo?= foo-1.0
5621: . endif
5622: .endif # IS_BUILTIN.foo
5623:
5624: .if !defined(USE_BUILTIN.foo)
5625: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
5626: . if defined(BUILTIN_PKG.foo)
5627: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
5628: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
5629: USE_BUILTIN.foo!= \
5630: ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo} \
5631: && ${ECHO} "yes" || ${ECHO} "no"
5632: . endif
5633: . endfor
5634: . endif
5635: .endif # USE_BUILTIN.foo
5636:
5637: CHECK_BUILTIN.foo?= no
5638: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
5639: #
5640: # Here we place code that depends on whether USE_BUILTIN.foo is set to
5641: # "yes" or "no".
5642: #
5643: .endif # CHECK_BUILTIN.foo
5644: </pre>
5645: <p>The first section sets
5646: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5647: depending on if <em class="replaceable"><code>pkg</code></em> really exists
5648: in the base system. This should not be a base system software
5649: with similar functionality to <em class="replaceable"><code>pkg</code></em>;
5650: it should only be “<span class="quote">yes</span>” if the actual package is
5651: included as part of the base system. This variable is only
5652: used internally within the <code class="filename">builtin.mk</code>
5653: file.</p>
5654: <p>The second section sets
5655: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
5656: to the version of <em class="replaceable"><code>pkg</code></em> in the base
5657: system if it exists (if
5658: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5659: is “<span class="quote">yes</span>”). This variable is only used internally
5660: within the <code class="filename">builtin.mk</code> file.</p>
5661: <p>The third section sets
5662: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5663: and is <span class="emphasis"><em>required</em></span> in all
5664: <code class="filename">builtin.mk</code> files. The code in this
5665: section must make the determination whether the built-in
5666: software is adequate to satisfy the dependencies listed in
5667: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
5668: This is typically done by comparing
5669: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
5670: against each of the dependencies in
5671: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
5672: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5673: <span class="emphasis"><em>must</em></span> be set to the correct value by the
5674: end of the <code class="filename">builtin.mk</code> file. Note that
5675: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5676: may be “<span class="quote">yes</span>” even if
5677: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5678: is “<span class="quote">no</span>” because we may make the determination
5679: that the built-in version of the software is similar enough to
5680: be used as a replacement.</p>
5681: <p>The last section is guarded by
5682: <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
5683: and includes code that uses the value of
5684: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5685: set in the previous section. This typically includes, e.g.,
5686: adding additional dependency restrictions and listing additional
5687: files to symlink into <code class="filename">${BUILDLINK_DIR}</code> (via
5688: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).</p>
5689: </div>
5690: <div class="sect2" lang="en">
5691: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 5692: <a name="native-or-pkgsrc-preference"></a>14.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
1.1 dsieger 5693: <p>When building packages, it's possible to choose whether to set
5694: a global preference for using either the built-in (native)
5695: version or the pkgsrc version of software to satisfy a
5696: dependency. This is controlled by setting
5697: <code class="varname">PREFER_PKGSRC</code> and
5698: <code class="varname">PREFER_NATIVE</code>. These variables take values
5699: of either “<span class="quote">yes</span>”, “<span class="quote">no</span>”, or a list of
5700: packages. <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
5701: use the pkgsrc versions of software, while
5702: <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
5703: built-in versions. Preferences are determined by the most
5704: specific instance of the package in either
5705: <code class="varname">PREFER_PKGSRC</code> or
5706: <code class="varname">PREFER_NATIVE</code>. If a package is specified
5707: in neither or in both variables, then
5708: <code class="varname">PREFER_PKGSRC</code> has precedence over
5709: <code class="varname">PREFER_NATIVE</code>. For example, to require
5710: using pkgsrc versions of software for all but the most basic
5711: bits on a NetBSD system, you can set:</p>
5712: <pre class="programlisting">
5713: PREFER_PKGSRC= yes
5714: PREFER_NATIVE= getopt skey tcp_wrappers
5715: </pre>
5716: <p>A package <span class="emphasis"><em>must</em></span> have a
5717: <code class="filename">builtin.mk</code>
5718: file to be listed in <code class="varname">PREFER_NATIVE</code>,
5719: otherwise it is simply ignored in that list.</p>
5720: </div>
5721: </div>
5722: </div>
5723: <div class="chapter" lang="en">
5724: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 5725: <a name="pkginstall"></a>Chapter 15. The pkginstall framework</h2></div></div></div>
1.1 dsieger 5726: <div class="toc">
5727: <p><b>Table of Contents</b></p>
5728: <dl>
1.6 rillig 5729: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">15.1. Files and directories outside the installation prefix</a></span></dt>
1.1 dsieger 5730: <dd><dl>
1.6 rillig 5731: <dt><span class="sect2"><a href="#dirs-outside-prefix">15.1.1. Directory manipulation</a></span></dt>
5732: <dt><span class="sect2"><a href="#files-outside-prefix">15.1.2. File manipulation</a></span></dt>
1.1 dsieger 5733: </dl></dd>
1.6 rillig 5734: <dt><span class="sect1"><a href="#conf-files">15.2. Configuration files</a></span></dt>
1.1 dsieger 5735: <dd><dl>
1.6 rillig 5736: <dt><span class="sect2"><a href="#conf-files-sysconfdir">15.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
5737: <dt><span class="sect2"><a href="#conf-files-configure">15.2.2. Telling the software where configuration files are</a></span></dt>
5738: <dt><span class="sect2"><a href="#conf-files-patching">15.2.3. Patching installations</a></span></dt>
5739: <dt><span class="sect2"><a href="#conf-files-disable">15.2.4. Disabling handling of configuration files</a></span></dt>
5740: </dl></dd>
5741: <dt><span class="sect1"><a href="#rcd-scripts">15.3. System startup scripts</a></span></dt>
5742: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">15.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
5743: <dt><span class="sect1"><a href="#users-and-groups">15.4. System users and groups</a></span></dt>
5744: <dt><span class="sect1"><a href="#shells">15.5. System shells</a></span></dt>
5745: <dd><dl><dt><span class="sect2"><a href="#shells-disable">15.5.1. Disabling shell registration</a></span></dt></dl></dd>
5746: <dt><span class="sect1"><a href="#fonts">15.6. Fonts</a></span></dt>
5747: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">15.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
1.1 dsieger 5748: </dl>
5749: </div>
5750: <p>This chapter describes the framework known as
5751: <code class="literal">pkginstall</code>, whose key features are:</p>
5752: <div class="itemizedlist"><ul type="disc">
5753: <li><p>Generic installation and manipulation of directories and files
5754: outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
5755: <li><p>Automatic handling of configuration files during installation,
5756: provided that packages are correctly designed.</p></li>
5757: <li><p>Generation and installation of system startup scripts.</p></li>
5758: <li><p>Registration of system users and groups.</p></li>
5759: <li><p>Registration of system shells.</p></li>
5760: <li><p>Automatic updating of fonts databases.</p></li>
5761: </ul></div>
5762: <p>The following sections inspect each of the above points in detail.</p>
5763: <p>You may be thinking that many of the things described here could be
5764: easily done with simple code in the package's post-installation target
5765: (<code class="literal">post-install</code>). <span class="emphasis"><em>This is incorrect</em></span>,
5766: as the code in them is only executed when building from source. Machines
5767: using binary packages could not benefit from it at all (as the code itself
5768: could be unavailable). Therefore, the only way to achieve any of the items
5769: described above is by means of the installation scripts, which are
5770: automatically generated by pkginstall.</p>
5771: <div class="sect1" lang="en">
5772: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 5773: <a name="files-and-dirs-outside-prefix"></a>15.1. Files and directories outside the installation prefix</h2></div></div></div>
1.1 dsieger 5774: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
5775: of files and directories that belong to a package. The names used in it
5776: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
5777: which means that it cannot register files outside this directory (absolute
5778: path names are not allowed). Despite this restriction, some packages need
5779: to install files outside this location; e.g., under
5780: <code class="filename">${VARBASE}</code> or
5781: <code class="filename">${PKG_SYSCONFDIR}</code>. The only way to achieve this
5782: is to create such files during installation time by using
5783: installation scripts.</p>
5784: <p>The generic installation scripts are shell scripts that can
5785: contain arbitrary code. The list of scripts to execute is taken from
5786: the <code class="varname">INSTALL_FILE</code> variable, which defaults to
5787: <code class="filename">INSTALL</code>. A similar variable exists for package
5788: removal (<code class="varname">DEINSTALL_FILE</code>, whose default is
5789: <code class="filename">DEINSTALL</code>). These scripts can run arbitrary
5790: commands, so they have the potential to create and manage files
5791: anywhere in the file system.</p>
5792: <p>Using these general installation files is not recommended, but
5793: may be needed in some special cases. One reason for avoiding them is
5794: that the user has to trust the packager that there is no unwanted or
5795: simply erroneous code included in the installation script. Also,
5796: previously there were many similar scripts for the same functionality,
5797: and fixing a common error involved finding and changing all of
5798: them.</p>
5799: <p>The pkginstall framework offers another, standardized way. It
5800: provides generic scripts to abstract the manipulation of such files
5801: and directories based on variables set in the package's
5802: <code class="filename">Makefile</code>. The rest of this section describes
5803: these variables.</p>
5804: <div class="sect2" lang="en">
5805: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 5806: <a name="dirs-outside-prefix"></a>15.1.1. Directory manipulation</h3></div></div></div>
1.1 dsieger 5807: <p>The following variables can be set to request the creation of
5808: directories anywhere in the file system:</p>
5809: <div class="itemizedlist"><ul type="disc">
5810: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
5811: contain a list of directories that should be created and should attempt
5812: to be destroyed by the installation scripts. The difference between
5813: the two is that the latter prompts the administrator to remove any
5814: directories that may be left after deinstallation (because they were
5815: not empty), while the former does not.</p></li>
5816: <li>
5817: <p><code class="varname">MAKE_DIRS_PERMS</code> and
5818: <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
5819: which directories should be created and should attempt to be destroyed
5820: by the installation scripts. Each tuple holds the following values,
5821: separated by spaces: the directory name, its owner, its group and its
5822: numerical mode. For example:</p>
5823: <pre class="programlisting">
5824: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
5825: </pre>
5826: <p>The difference between the two is exactly the same as their
5827: non-<code class="varname">PERMS</code> counterparts.</p>
5828: </li>
5829: </ul></div>
5830: </div>
5831: <div class="sect2" lang="en">
5832: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 5833: <a name="files-outside-prefix"></a>15.1.2. File manipulation</h3></div></div></div>
1.1 dsieger 5834: <p>Creating non-empty files outside the installation prefix is tricky
5835: because the <code class="filename">PLIST</code> forces all files to be inside it.
5836: To overcome this problem, the only solution is to extract the file in the
5837: known place (i.e., inside the installation prefix) and copy it to the
5838: appropriate location during installation (done by the installation scripts
5839: generated by pkginstall). We will call the former the <span class="emphasis"><em>master
5840: file</em></span> in the following paragraphs, which describe the variables
5841: that can be used to automatically and consistently handle files outside the
5842: installation prefix:</p>
5843: <div class="itemizedlist"><ul type="disc">
5844: <li>
5845: <p><code class="varname">CONF_FILES</code> and
5846: <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
5847: During installation time, the master file is copied to the target one
5848: if and only if the latter does not exist. Upon deinstallation, the
5849: target file is removed provided that it was not modified by the
5850: installation.</p>
5851: <p>The difference between the two is that the latter prompts the
5852: administrator to remove any files that may be left after
5853: deinstallation (because they were not empty), while the former does
5854: not.</p>
5855: </li>
5856: <li>
5857: <p><code class="varname">CONF_FILES_PERMS</code> and
5858: <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
5859: files as well as their target locations. For each of them, it also
5860: specifies their owner, their group and their numeric permissions, in
5861: this order. For example:</p>
5862: <pre class="programlisting">
5863: SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
5864: </pre>
5865: <p>The difference between the two is exactly the same as their
5866: non-<code class="varname">PERMS</code> counterparts.</p>
5867: </li>
5868: </ul></div>
5869: </div>
5870: </div>
5871: <div class="sect1" lang="en">
5872: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 5873: <a name="conf-files"></a>15.2. Configuration files</h2></div></div></div>
1.1 dsieger 5874: <p>Configuration files are special in the sense that they are installed
5875: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
5876: need special treatment during installation (most of which is automated by
5877: pkginstall). The main concept you must bear in mind is that files marked
5878: as configuration files are automatically copied to the right place (somewhere
5879: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
5880: and only if</em></span> they didn't exist before. Similarly, they will not
5881: be removed if they have local modifications. This ensures that
5882: administrators never lose any custom changes they may have made.</p>
5883: <div class="sect2" lang="en">
5884: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 5885: <a name="conf-files-sysconfdir"></a>15.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</h3></div></div></div>
1.1 dsieger 5886: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
5887: specifies where configuration files shall be installed. Its contents are
5888: set based upon the following variables:</p>
5889: <div class="itemizedlist"><ul type="disc">
5890: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
5891: directory. Defaults to <code class="filename">${PREFIX}/etc</code> although it may
5892: be overridden by the user to point to his preferred location (e.g.,
5893: <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
5894: Packages must not use it directly.</p></li>
5895: <li>
5896: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
5897: <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
5898: for the package being built shall be installed. The definition of this
5899: variable only makes sense in the package's
5900: <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
5901: <p>As an example, consider the Apache package,
5902: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/apache2/README.html" target="_top"><code class="filename">www/apache2</code></a>, which places its
5903: configuration files under the
5904: <code class="filename">httpd/</code> subdirectory of
5905: <code class="varname">PKG_SYSCONFBASE</code>. This should be set in the package
5906: Makefile.</p>
5907: </li>
5908: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
5909: variable that holds this package's configuration directory (if
5910: different from <code class="varname">PKG_SYSCONFBASE</code>). It defaults to
5911: <code class="varname">PKGBASE</code>'s value, and is always prefixed with
5912: <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
5913: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
5914: directory where the configuration files for the package identified by
5915: <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
5916: </ul></div>
5917: <p>Based on the above variables, pkginstall determines the value of
5918: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
5919: variable that can be used within a package to refer to its configuration
5920: directory. The algorithm used to set its value is basically the
5921: following:</p>
5922: <div class="orderedlist"><ol type="1">
5923: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
5924: its value is used.</p></li>
5925: <li><p>If the previous variable is not defined but
5926: <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
5927: <code class="filename">Makefile</code>, the resulting value is
5928: <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
5929: <li><p>Otherwise, it is set to
5930: <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
5931: </ol></div>
5932: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
1.10 hubertf 5933: automatically added to <code class="filename">OWN_DIRS</code>. See <a class="xref" href="#dirs-outside-prefix" title="15.1.1. Directory manipulation">Section 15.1.1, “Directory manipulation”</a> what this means.</p>
1.1 dsieger 5934: </div>
5935: <div class="sect2" lang="en">
5936: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 5937: <a name="conf-files-configure"></a>15.2.2. Telling the software where configuration files are</h3></div></div></div>
1.1 dsieger 5938: <p>Given that pkgsrc (and users!) expect configuration files to be in a
5939: known place, you need to teach each package where it shall install its
5940: files. In some cases you will have to patch the package Makefiles to
5941: achieve it. If you are lucky, though, it may be as easy as passing an
5942: extra flag to the configuration script; this is the case of GNU Autoconf-
5943: generated files:</p>
5944: <pre class="programlisting">
5945: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
5946: </pre>
5947: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
5948: for</em></span> its configuration files, not where they will be originally
5949: installed (although the difference is never explicit,
5950: unfortunately).</p>
5951: </div>
5952: <div class="sect2" lang="en">
5953: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 5954: <a name="conf-files-patching"></a>15.2.3. Patching installations</h3></div></div></div>
1.1 dsieger 5955: <p>As said before, pkginstall automatically handles configuration files.
5956: This means that <span class="strong"><strong>the packages themselves must not
5957: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
5958: directly</strong></span>. Bad news is that many software installation scripts
5959: will, out of the box, mess with the contents of that directory. So what is
5960: the correct procedure to fix this issue?</p>
5961: <p>You must teach the package (usually by manually patching it) to
5962: install any configuration files under the examples hierarchy,
5963: <code class="filename">share/examples/${PKGBASE}/</code>. This way, the
5964: <code class="filename">PLIST</code> registers them and the administrator always
5965: has the original copies available.</p>
5966: <p>Once the required configuration files are in place (i.e., under the
5967: examples hierarchy), the pkginstall framework can use them as master copies
5968: during the package installation to update what is in
5969: <code class="filename">${PKG_SYSCONFDIR}</code>. To achieve this, the variables
5970: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
1.10 hubertf 5971: used. Check out <a class="xref" href="#files-outside-prefix" title="15.1.2. File manipulation">Section 15.1.2, “File manipulation”</a> for information
1.1 dsieger 5972: about their syntax and their purpose. Here is an example, taken from the
5973: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/mail/mutt/README.html" target="_top"><code class="filename">mail/mutt</code></a> package:</p>
5974: <pre class="programlisting">
5975: EGDIR= ${PREFIX}/share/doc/mutt/samples
5976: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
5977: </pre>
5978: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
5979: package and has no meaning outside it.</p>
5980: </div>
5981: <div class="sect2" lang="en">
5982: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 5983: <a name="conf-files-disable"></a>15.2.4. Disabling handling of configuration files</h3></div></div></div>
1.1 dsieger 5984: <p>The automatic copying of config files can be toggled by setting the
5985: environment variable <code class="varname">PKG_CONFIG</code> prior to package
5986: installation.</p>
5987: </div>
5988: </div>
5989: <div class="sect1" lang="en">
5990: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 5991: <a name="rcd-scripts"></a>15.3. System startup scripts</h2></div></div></div>
1.1 dsieger 5992: <p>System startup scripts are special files because they must be
5993: installed in a place known by the underlying OS, usually outside the
1.10 hubertf 5994: installation prefix. Therefore, the same rules described in <a class="xref" href="#files-and-dirs-outside-prefix" title="15.1. Files and directories outside the installation prefix">Section 15.1, “Files and directories outside the installation prefix”</a> apply, and the same solutions
1.1 dsieger 5995: can be used. However, pkginstall provides a special mechanism to handle
5996: these files.</p>
5997: <p>In order to provide system startup scripts, the package has
5998: to:</p>
5999: <div class="orderedlist"><ol type="1">
6000: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
6001: the <code class="literal">.sh</code> suffix appended. Considering the
6002: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/print/cups/README.html" target="_top"><code class="filename">print/cups</code></a> package as an example, it has a
6003: <code class="filename">cupsd.sh</code> in its files directory.</p></li>
6004: <li>
6005: <p>Tell pkginstall to handle it, appending the name of the script,
6006: without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
6007: Continuing the previous example:</p>
6008: <pre class="programlisting">
6009: RCD_SCRIPTS+= cupsd
6010: </pre>
6011: </li>
6012: </ol></div>
6013: <p>Once this is done, pkginstall will do the following steps for each
6014: script in an automated fashion:</p>
6015: <div class="orderedlist"><ol type="1">
6016: <li><p>Process the file found in the files directory applying all the
6017: substitutions described in the <code class="filename">FILES_SUBST</code>
6018: variable.</p></li>
6019: <li><p>Copy the script from the files directory to the examples
6020: hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>. Note
6021: that this master file must be explicitly registered in the
6022: <code class="filename">PLIST</code>.</p></li>
6023: <li><p>Add code to the installation scripts to copy the startup script
6024: from the examples hierarchy into the system-wide startup scripts
6025: directory.</p></li>
6026: </ol></div>
6027: <div class="sect2" lang="en">
6028: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 6029: <a name="rcd-scripts-disable"></a>15.3.1. Disabling handling of system startup scripts</h3></div></div></div>
1.1 dsieger 6030: <p>The automatic copying of config files can be toggled by setting the
6031: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
6032: installation. Note that the scripts will be always copied inside the
6033: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
6034: matter what the value of this variable is.</p>
6035: </div>
6036: </div>
6037: <div class="sect1" lang="en">
6038: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6039: <a name="users-and-groups"></a>15.4. System users and groups</h2></div></div></div>
1.1 dsieger 6040: <p>If a package needs to create special users and/or groups during
6041: installation, it can do so by using the pkginstall framework.</p>
6042: <p>Users can be created by adding entries to the
6043: <code class="varname">PKG_USERS</code> variable. Each entry has the following
6044: syntax:</p>
6045: <pre class="programlisting">
6046: user:group
6047: </pre>
6048: <p>Further specification of user details may be done by setting
6049: per-user variables.
6050: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the
6051: numeric UID for the user.
6052: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the
6053: user's description or comment.
6054: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the
6055: user's home directory, and defaults to
6056: <code class="filename">/nonexistent</code> if not specified.
6057: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the
6058: user's shell, and defaults to <code class="filename">/sbin/nologin</code> if
6059: not specified.</p>
6060: <p>Similarly, groups can be created by adding entries to the
6061: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
6062: <pre class="programlisting">
6063: group
6064: </pre>
6065: <p>The numeric GID of the group may be set by defining
6066: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
6067: <p>If a package needs to create the users and groups at an earlier
6068: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
6069: either <code class="literal">configure</code> or <code class="literal">build</code> to
6070: indicate the phase before which the users and groups are created. In
6071: this case, the numeric UIDs and GIDs of the created users and groups
6072: are automatically hardcoded into the final installation scripts.</p>
6073: </div>
6074: <div class="sect1" lang="en">
6075: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6076: <a name="shells"></a>15.5. System shells</h2></div></div></div>
1.1 dsieger 6077: <p>Packages that install system shells should register them in the shell
6078: database, <code class="filename">/etc/shells</code>, to make things easier to the
6079: administrator. This must be done from the installation scripts to keep
6080: binary packages working on any system. pkginstall provides an easy way to
6081: accomplish this task.</p>
6082: <p>When a package provides a shell interpreter, it has to set the
6083: <code class="varname">PKG_SHELL</code> variable to its absolute file name. This will
6084: add some hooks to the installation scripts to handle it. Consider the
6085: following example, taken from <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/shells/zsh/README.html" target="_top"><code class="filename">shells/zsh</code></a>:</p>
6086: <pre class="programlisting">
6087: PKG_SHELL= ${PREFIX}/bin/zsh
6088: </pre>
6089: <div class="sect2" lang="en">
6090: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 6091: <a name="shells-disable"></a>15.5.1. Disabling shell registration</h3></div></div></div>
1.1 dsieger 6092: <p>The automatic registration of shell interpreters can be disabled by
6093: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
6094: environment variable to <code class="literal">NO</code>.</p>
6095: </div>
6096: </div>
6097: <div class="sect1" lang="en">
6098: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6099: <a name="fonts"></a>15.6. Fonts</h2></div></div></div>
1.1 dsieger 6100: <p>Packages that install X11 fonts should update the database files
6101: that index the fonts within each fonts directory. This can easily be
6102: accomplished within the pkginstall framework.</p>
6103: <p>When a package installs X11 fonts, it must list the directories in
6104: which fonts are installed in the
6105: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
6106: where <em class="replaceable"><code>type</code></em> can be one of “<span class="quote">ttf</span>”,
6107: “<span class="quote">type1</span>” or “<span class="quote">x11</span>”. This will add hooks to the
6108: installation scripts to run the appropriate commands to update the fonts
6109: database files within each of those directories. For convenience, if the
6110: directory path is relative, it is taken to be relative to the package's
6111: installation prefix. Consider the following example, taken from <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/fonts/dbz-ttf/README.html" target="_top"><code class="filename">fonts/dbz-ttf</code></a>:</p>
6112: <pre class="programlisting">
6113: FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
6114: </pre>
6115: <div class="sect2" lang="en">
6116: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 6117: <a name="fonts-disable"></a>15.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
1.1 dsieger 6118: <p>The automatic update of fonts databases can be disabled by
6119: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
6120: environment variable to <code class="literal">NO</code>.</p>
6121: </div>
6122: </div>
6123: </div>
6124: <div class="chapter" lang="en">
6125: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 6126: <a name="options"></a>Chapter 16. Options handling</h2></div></div></div>
1.1 dsieger 6127: <div class="toc">
6128: <p><b>Table of Contents</b></p>
6129: <dl>
1.6 rillig 6130: <dt><span class="sect1"><a href="#global-default-options">16.1. Global default options</a></span></dt>
6131: <dt><span class="sect1"><a href="#converting-to-options">16.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
6132: <dt><span class="sect1"><a href="#option-names">16.3. Option Names</a></span></dt>
1.7 rillig 6133: <dt><span class="sect1"><a href="#option-build">16.4. Determining the options of dependencies</a></span></dt>
1.1 dsieger 6134: </dl>
6135: </div>
6136: <p>Many packages have the ability to be built to support different
6137: sets of features. <code class="filename">bsd.options.mk</code> is a framework
6138: in pkgsrc that provides generic handling of those options that
6139: determine different ways in which the packages can be built. It's
6140: possible for the user to specify exactly which sets of options will be
6141: built into a package or to allow a set of global default options
6142: apply.</p>
1.7 rillig 6143: <p>There are two broad classes of behaviors that one might want to
6144: control via options. One is whether some particular feature is
6145: enabled in a program that will be built anyway, often by including or
6146: not including a dependency on some other package. The other is
6147: whether or not an additional program will be built as part of the
6148: package. Generally, it is better to make a split package for such
6149: additional programs instead of using options, because it enables
6150: binary packages to be built which can then be added separately. For
6151: example, the foo package might have minimal dependencies (those
6152: packages without which foo doesn't make sense), and then the foo-gfoo
6153: package might include the GTK frontend program gfoo. This is better
6154: than including a gtk option to foo that adds gfoo, because either that
6155: option is default, in which case binary users can't get foo without
6156: gfoo, or not default, in which case they can't get gfoo. With split
6157: packages, they can install foo without having GTK, and later decide to
6158: install gfoo (pulling in GTK at that time). This is an advantage to
6159: source users too, avoiding the need for rebuilds.</p>
6160: <p>Plugins with widely varying dependencies should usually be split
6161: instead of options.</p>
6162: <p>It is often more work to maintain split packages, especially if
6163: the upstream package does not support this. The decision of split
6164: vs. option should be made based on the likelihood that users will want
6165: or object to the various pieces, the size of the dependencies that are
6166: included, and the amount of work.</p>
6167: <p>A further consideration is licensing. Non-free parts, or parts
6168: that depend on non-free dependencies (especially plugins) should
6169: almost always be split if feasible.</p>
1.1 dsieger 6170: <div class="sect1" lang="en">
6171: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6172: <a name="global-default-options"></a>16.1. Global default options</h2></div></div></div>
1.1 dsieger 6173: <p>Global default options are listed in
6174: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
6175: that should be built into every package if that option is supported.
1.10 hubertf 6176: This variable should be set in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.</p>
1.1 dsieger 6177: </div>
6178: <div class="sect1" lang="en">
6179: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6180: <a name="converting-to-options"></a>16.2. Converting packages to use <code class="filename">bsd.options.mk</code>
1.1 dsieger 6181: </h2></div></div></div>
6182: <p>The following example shows how
6183: <code class="filename">bsd.options.mk</code> should be used
6184: by the hypothetical ``wibble'' package, either in the package
6185: <code class="filename">Makefile</code>, or in a file,
6186: e.g. <code class="filename">options.mk</code>, that is included by the
6187: main package <code class="filename">Makefile</code>.</p>
6188: <pre class="programlisting">
6189: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
6190: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
6191: PKG_OPTIONS_OPTIONAL_GROUPS= database
6192: PKG_OPTIONS_GROUP.database= mysql pgsql
6193: PKG_SUGGESTED_OPTIONS= wibble-foo
6194: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
6195: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
6196:
6197: .include "../../mk/bsd.prefs.mk"
6198:
6199: # this package was previously named wibble2
6200: .if defined(PKG_OPTIONS.wibble2)
6201: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
6202: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
6203: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
6204: .endif
6205:
6206: .include "../../mk/bsd.options.mk"
6207:
6208: # Package-specific option-handling
6209:
6210: ###
6211: ### FOO support
6212: ###
6213: .if !empty(PKG_OPTIONS:Mwibble-foo)
6214: CONFIGURE_ARGS+= --enable-foo
6215: .endif
6216:
6217: ###
6218: ### LDAP support
6219: ###
6220: .if !empty(PKG_OPTIONS:Mldap)
6221: . include "../../databases/openldap-client/buildlink3.mk"
6222: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
6223: .endif
6224:
6225: ###
6226: ### database support
6227: ###
6228: .if !empty(PKG_OPTIONS:Mmysql)
6229: . include "../../mk/mysql.buildlink3.mk"
6230: .endif
6231: .if !empty(PKG_OPTIONS:Mpgsql)
6232: . include "../../mk/pgsql.buildlink3.mk"
6233: .endif
6234: </pre>
6235: <p>The first section contains the information about which build
6236: options are supported by the package, and any default options settings
6237: if needed.</p>
6238: <div class="orderedlist"><ol type="1">
6239: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
1.10 hubertf 6240: <a class="citerefentry" 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
1.1 dsieger 6241: options. It should be set to
6242: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
6243: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is not defined
6244: at the point where the options are processed.</p></li>
6245: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
6246: build options supported by the package.</p></li>
6247: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
6248: list of names of groups of mutually exclusive options. The options in
6249: each group are listed in
6250: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
6251: The most specific setting of any option from the group takes
6252: precedence over all other options in the group. Options from the
6253: groups will be automatically added to
6254: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
6255: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
6256: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
6257: packages will fail if no option from the group is
6258: selected.</p></li>
6259: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
6260: of names of sets of options. At least one option from each set must
6261: be selected. The options in each set are listed in
6262: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
6263: Options from the sets will be automatically added to
6264: <code class="varname">PKG_SUPPORTED_OPTIONS</code>. Building the package will
6265: fail if no option from the set is selected.</p></li>
6266: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
6267: build options which are enabled by default.</p></li>
6268: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
6269: of
6270: “<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>”
1.10 hubertf 6271: pairs that map legacy <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> variables to
1.1 dsieger 6272: their option counterparts. Pairs should be added with
6273: “<span class="quote">+=</span>” to keep the listing of global legacy variables. A
6274: warning will be issued if the user uses a legacy
6275: variable.</p></li>
6276: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
6277: of
6278: “<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>”
6279: pairs that map options that have been renamed to their new
6280: counterparts. Pairs should be added with “<span class="quote">+=</span>” to keep
6281: the listing of global legacy options. A warning will be issued if
6282: the user uses a legacy option.</p></li>
6283: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
6284: options implied by deprecated variables used. This can be used for
6285: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
6286: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
6287: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
6288: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
6289: a list of warnings about deprecated variables or options used, and
6290: what to use instead.</p></li>
6291: </ol></div>
6292: <p>A package should never modify
6293: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
6294: <code class="varname">PKG_OPTIONS_VAR</code>. These are strictly user-settable.
6295: To suggest a default set of options, use
6296: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
6297: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
6298: including <code class="filename">bsd.options.mk</code>. If none of
6299: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
6300: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
6301: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
6302: happen with platform-specific options if none of them is supported on
6303: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
6304: empty list and the package is otherwise treated as not using the
6305: options framework.</p>
6306: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
6307: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
6308: build options, properly filtered to remove unsupported and duplicate
6309: options.</p>
6310: <p>The remaining sections contain the logic that is specific to
6311: each option. The correct way to check for an option is to check
6312: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
6313: <pre class="programlisting">
6314: .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
6315: </pre>
6316: </div>
6317: <div class="sect1" lang="en">
6318: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6319: <a name="option-names"></a>16.3. Option Names</h2></div></div></div>
1.1 dsieger 6320: <p>Options that enable similar features in different packages (like
6321: optional support for a library) should use a common name in all
6322: packages that support it (like the name of the library). If another
6323: package already has an option with the same meaning, use the same
6324: name.</p>
6325: <p>Options that enable features specific to one package, where it's
6326: unlikely that another (unrelated) package has the same (or a similar)
6327: optional feature, should use a name prefixed with
6328: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
6329: <p>If a group of related packages share an optional feature
6330: specific to that group, prefix it with the name of the
6331: “<span class="quote">main</span>” package
6332: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
6333: <p>For new options, add a line to
6334: <code class="filename">mk/defaults/options.description</code>. Lines have two
6335: fields, separated by tab. The first field is the option name, the
6336: second its description. The description should be a whole sentence
6337: (starting with an uppercase letter and ending with a period) that
6338: describes what enabling the option does. E. g. “<span class="quote">Enable ispell
6339: support.</span>” The file is sorted by option names.</p>
6340: </div>
1.7 rillig 6341: <div class="sect1" lang="en">
6342: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
6343: <a name="option-build"></a>16.4. Determining the options of dependencies</h2></div></div></div>
1.10 hubertf 6344: <p>When writing <a class="link" href="#buildlink3.mk"><code class="filename">buildlink3.mk</code></a> files, it is often necessary to list
1.7 rillig 6345: different dependencies based on the options with which the package was
6346: built. For querying these options, the file
6347: <code class="filename">pkgsrc/mk/pkg-build-options.mk</code> should be used. A
6348: typical example looks like this:</p>
6349: <pre class="programlisting">
6350: pkgbase := libpurple
6351: .include "../../mk/pkg-build-options.mk"
6352:
6353: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
6354: ...
6355: .endif
6356: </pre>
6357: <p>Including <code class="filename">pkg-build-options.mk</code> here will set
6358: the variable <code class="varname">PKG_BUILD_OPTIONS.libpurple</code> to the build
6359: options of the libpurple package, which can then be queried like
6360: <code class="varname">PKG_OPTIONS</code> in the <code class="filename">options.mk</code>
6361: file. See the file <code class="filename">pkg-build-options.mk</code> for more
6362: details.</p>
6363: </div>
1.1 dsieger 6364: </div>
6365: <div class="chapter" lang="en">
6366: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 6367: <a name="build"></a>Chapter 17. The build process</h2></div></div></div>
1.1 dsieger 6368: <div class="toc">
6369: <p><b>Table of Contents</b></p>
6370: <dl>
1.6 rillig 6371: <dt><span class="sect1"><a href="#build.intro">17.1. Introduction</a></span></dt>
6372: <dt><span class="sect1"><a href="#build.prefix">17.2. Program location</a></span></dt>
6373: <dt><span class="sect1"><a href="#build.builddirs">17.3. Directories used during the build process</a></span></dt>
6374: <dt><span class="sect1"><a href="#build.running">17.4. Running a phase</a></span></dt>
6375: <dt><span class="sect1"><a href="#build.fetch">17.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
6376: <dd><dl>
6377: <dt><span class="sect2"><a href="#build.fetch.what">17.5.1. What to fetch and where to get it from</a></span></dt>
6378: <dt><span class="sect2"><a href="#build.fetch.how">17.5.2. How are the files fetched?</a></span></dt>
6379: </dl></dd>
6380: <dt><span class="sect1"><a href="#build.checksum">17.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
6381: <dt><span class="sect1"><a href="#build.extract">17.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
6382: <dt><span class="sect1"><a href="#build.patch">17.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
6383: <dt><span class="sect1"><a href="#build.tools">17.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
6384: <dt><span class="sect1"><a href="#build.wrapper">17.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
6385: <dt><span class="sect1"><a href="#build.configure">17.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
6386: <dt><span class="sect1"><a href="#build.build">17.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
6387: <dt><span class="sect1"><a href="#build.test">17.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
6388: <dt><span class="sect1"><a href="#build.install">17.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
6389: <dt><span class="sect1"><a href="#build.package">17.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
6390: <dt><span class="sect1"><a href="#build.clean">17.16. Cleaning up</a></span></dt>
6391: <dt><span class="sect1"><a href="#build.helpful-targets">17.17. Other helpful targets</a></span></dt>
1.1 dsieger 6392: </dl>
6393: </div>
6394: <div class="sect1" lang="en">
6395: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6396: <a name="build.intro"></a>17.1. Introduction</h2></div></div></div>
1.1 dsieger 6397: <p>This chapter gives a detailed description on how a package is
6398: built. Building a package is separated into different
6399: <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
6400: <code class="varname">build</code>, <code class="varname">install</code>), all of which are
6401: described in the following sections. Each phase is splitted into
6402: so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
6403: containing phase, prefixed by one of <code class="varname">pre-</code>,
6404: <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
6405: <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
6406: of the actual work is done in the <code class="varname">do-*</code> stages.</p>
6407: <p>Never override the regular targets (like
6408: <code class="varname">fetch</code>), if you have to, override the
6409: <code class="varname">do-*</code> ones instead.</p>
6410: <p>The basic steps for building a program are always the same. First
6411: the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
6412: the local system and then extracted. After any pkgsrc-specific patches
6413: to compile properly are applied, the software can be configured, then
6414: built (usually by compiling), and finally the generated binaries, etc.
6415: can be put into place on the system.</p>
6416: <p>To get more details about what is happening at each step,
6417: you can set the <code class="varname">PKG_VERBOSE</code> variable, or the
6418: <code class="varname">PATCH_DEBUG</code> variable if you are just interested
6419: in more details about the <span class="emphasis"><em>patch</em></span> step.</p>
6420: </div>
6421: <div class="sect1" lang="en">
6422: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6423: <a name="build.prefix"></a>17.2. Program location</h2></div></div></div>
1.1 dsieger 6424: <p>Before outlining the process performed by the NetBSD package system in
6425: the next section, here's a brief discussion on where programs are
6426: installed, and which variables influence this.</p>
6427: <p>The automatic variable <code class="varname">PREFIX</code> indicates
6428: where all files of the final program shall be installed. It is
6429: usually set to <code class="varname">LOCALBASE</code>
6430: (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
6431: for pkgs in the <code class="filename">cross</code> category. The value of
6432: <code class="varname">PREFIX</code> needs to be put
6433: into the various places in the program's source where paths to
1.10 hubertf 6434: these files are encoded. See <a class="xref" href="#components.patches" title="11.3. patches/*">Section 11.3, “patches/*”</a> and <a class="xref" href="#fixes.libtool" title="19.3.1. Shared libraries - libtool">Section 19.3.1, “Shared libraries - libtool”</a> for more details.</p>
1.1 dsieger 6435: <p>When choosing which of these variables to use,
6436: follow the following rules:</p>
6437: <div class="itemizedlist"><ul type="disc">
6438: <li><p><code class="varname">PREFIX</code> always points to the location
6439: where the current pkg will be installed. When referring to a
6440: pkg's own installation path, use
6441: “<span class="quote">${PREFIX}</span>”.</p></li>
6442: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs
6443: are installed. If you need to construct a -I or -L argument
6444: to the compiler to find includes and libraries installed by
6445: another non-X11 pkg, use “<span class="quote">${LOCALBASE}</span>”. The name
6446: <code class="varname">LOCALBASE</code> stems from FreeBSD, which
6447: installed all packages in <code class="filename">/usr/local</code>. As
6448: pkgsrc leaves <code class="filename">/usr/local</code> for the system
6449: administrator, this variable is a misnomer.</p></li>
6450: <li><p><code class="varname">X11BASE</code> is where the actual X11
6451: distribution (from xsrc, etc.) is installed. When looking for
6452: <span class="emphasis"><em>standard</em></span> X11 includes (not those
6453: installed by a package), use “<span class="quote">${X11BASE}</span>”.</p></li>
6454: <li>
6455: <p>X11-based packages are special in that they may be
6456: installed in either <code class="varname">X11BASE</code> or
6457: <code class="varname">LOCALBASE</code>.</p>
6458: <p>Usually, X11 packages should be installed under
6459: <code class="varname">LOCALBASE</code> whenever possible. Note that you
6460: will need to include
6461: <code class="filename">../../mk/x11.buildlink3.mk</code> in them to
6462: request the presence of X11 and to get the right compilation
6463: flags.</p>
6464: <p>Even though, there are some packages that cannot be installed
6465: under <code class="varname">LOCALBASE</code>: those that come with app-defaults
6466: files. These packages are special and they must be placed under
6467: <code class="varname">X11BASE</code>. To accomplish this, set either
6468: <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
6469: your package.</p>
6470: <p>Some notes: If you need
6471: to find includes or libraries installed by a pkg that has
6472: <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
6473: its pkg <code class="filename">Makefile</code>, you need to look in
6474: <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
6475: <code class="filename">${LOCALBASE}</code>. To force installation of
6476: all X11 packages in <code class="varname">LOCALBASE</code>, the
6477: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a> package
6478: is enabled by default.</p>
6479: </li>
6480: <li><p><code class="varname">X11PREFIX</code> should be used to refer to
6481: the installed location of an X11
6482: package. <code class="varname">X11PREFIX</code> will be set to
6483: <code class="varname">X11BASE</code> if xpkgwedge is not installed, and
6484: to <code class="varname">LOCALBASE</code> if xpkgwedge is
6485: installed.</p></li>
6486: <li>
6487: <p>If xpkgwedge is installed, it is possible to have some
6488: packages installed in <code class="varname">X11BASE</code> and some in
6489: <code class="varname">LOCALBASE</code>. To determine the prefix of an
6490: installed package, the <code class="varname">EVAL_PREFIX</code>
6491: definition can be used. It takes pairs in the format
1.10 hubertf 6492: “<span class="quote">DIRNAME=<package></span>”, and the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>
1.1 dsieger 6493: variable <code class="varname">DIRNAME</code> will be set to the prefix
6494: of the installed package <package>, or
6495: “<span class="quote">${X11PREFIX}</span>” if the package is not
6496: installed.</p>
6497: <p>This is best illustrated by example.</p>
6498: <p>The following lines are taken from
6499: <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
6500: <pre class="programlisting">
6501: EVAL_PREFIX+= GTKDIR=gtk+
6502: CONFIGURE_ARGS+= --with-guile-prefix=${LOCALBASE:Q}
6503: CONFIGURE_ARGS+= --with-gtk-prefix=${GTKDIR:Q}
6504: CONFIGURE_ARGS+= --enable-multibyte
6505: </pre>
6506: <p>Specific defaults can be defined for the packages
6507: evaluated using <code class="varname">EVAL_PREFIX</code>, by using a
6508: definition of the form:</p>
6509: <pre class="programlisting">
6510: GTKDIR_DEFAULT= ${LOCALBASE}
6511: </pre>
6512: <p>where <code class="varname">GTKDIR</code> corresponds
6513: to the first definition in
6514: the <code class="varname">EVAL_PREFIX</code> pair.</p>
6515: </li>
6516: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.10 hubertf 6517: install files according to <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?hier+7+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">hier</span>(7)</span></a>, with the exception that
1.1 dsieger 6518: manual pages go into <code class="filename">${PREFIX}/man</code>, not
6519: <code class="filename">${PREFIX}/share/man</code>.</p></li>
6520: </ul></div>
6521: </div>
6522: <div class="sect1" lang="en">
6523: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6524: <a name="build.builddirs"></a>17.3. Directories used during the build process</h2></div></div></div>
1.14 ! jmcneill 6525: <p>When building a package, various directories are used to store
1.1 dsieger 6526: source files, temporary files, pkgsrc-internal files, and so on. These
6527: directories are explained here.</p>
6528: <p>Some of the directory variables contain relative pathnames. There
6529: are two common base directories for these relative directories:
6530: <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
6531: pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
6532: inside the package itself.</p>
6533: <div class="variablelist"><dl>
6534: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
6535: <dd><p>This is an absolute pathname that points to the pkgsrc
6536: root directory. Generally, you don't need
6537: it.</p></dd>
6538: <dt><span class="term"><code class="varname">PKGDIR</code></span></dt>
6539: <dd><p>This is an absolute pathname that points to the
6540: current package.</p></dd>
6541: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
6542: <dd><p>This is a pathname relative to
6543: <code class="varname">PKGSRCDIR</code> that points to the current
6544: package.</p></dd>
6545: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
6546: <dd><p>This is an absolute pathname pointing to the directory
6547: where all work takes place. The distfiles are extracted to this
6548: directory. It also contains temporary directories and log files used by
6549: the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
6550: the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
6551: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
6552: <dd><p>This is an absolute pathname pointing to the directory
6553: where the distfiles are extracted. It is usually a direct subdirectory
6554: of <code class="varname">WRKDIR</code>, and often it's the only directory entry
6555: that isn't hidden. This variable may be changed by a package
6556: <code class="filename">Makefile</code>.</p></dd>
6557: </dl></div>
1.14 ! jmcneill 6558: <p>The <code class="varname">CREATE_WRKDIR_SYMLINK</code> definition takes either
! 6559: the value <span class="emphasis"><em>yes</em></span> or <span class="emphasis"><em>no</em></span> and defaults
! 6560: to <span class="emphasis"><em>yes</em></span>. It indicates whether a symbolic link to the
! 6561: <code class="varname">WRKDIR</code> is to be created in the pkgsrc entry's directory.
! 6562: If users would like to have their pkgsrc trees behave in a
! 6563: read-only manner, then the value of
! 6564: <code class="varname">CREATE_WRKDIR_SYMLINK</code> should be set to
! 6565: <span class="emphasis"><em>no</em></span>.</p>
1.1 dsieger 6566: </div>
6567: <div class="sect1" lang="en">
6568: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6569: <a name="build.running"></a>17.4. Running a phase</h2></div></div></div>
1.10 hubertf 6570: <p>You can run a particular phase by typing <span class="command"><strong>make
1.1 dsieger 6571: phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
6572: phase. This will automatically run all phases that are required for this
6573: phase. The default phase is <code class="varname">build</code>, that is, when you
1.10 hubertf 6574: run <span class="command"><strong>make</strong></span> without parameters in a package directory,
1.1 dsieger 6575: the package will be built, but not installed.</p>
6576: </div>
6577: <div class="sect1" lang="en">
6578: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6579: <a name="build.fetch"></a>17.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.1 dsieger 6580: <p>The first step in building a package is to fetch the
6581: distribution files (distfiles) from the sites that are providing
6582: them. This is the task of the <span class="emphasis"><em>fetch</em></span>
6583: phase.</p>
6584: <div class="sect2" lang="en">
6585: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 6586: <a name="build.fetch.what"></a>17.5.1. What to fetch and where to get it from</h3></div></div></div>
1.1 dsieger 6587: <p>In simple cases, <code class="varname">MASTER_SITES</code>
6588: defines all URLs from where the distfile, whose name is
6589: derived from the <code class="varname">DISTNAME</code> variable, is
6590: fetched. The more complicated cases are described
6591: below.</p>
6592: <p>The variable <code class="varname">DISTFILES</code> specifies
6593: the list of distfiles that have to be fetched. Its value
6594: defaults to <code class="literal">${DISTNAME}${EXTRACT_SUFX}</code>,
6595: so that most packages don't need to define it at all.
6596: <code class="varname">EXTRACT_SUFX</code> is
6597: <code class="literal">.tar.gz</code> by default, but can be changed
6598: freely. Note that if your package requires additional
6599: distfiles to the default one, you cannot just append the
6600: additional filenames using the <code class="literal">+=</code>
6601: operator, but you have write for example:</p>
6602: <pre class="programlisting">
6603: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
6604: </pre>
6605: <p>Each distfile is fetched from a list of sites, usually
6606: <code class="varname">MASTER_SITES</code>. If the package has multiple
6607: <code class="varname">DISTFILES</code> or multiple
6608: <code class="varname">PATCHFILES</code> from different sites, you can
6609: set
6610: <code class="varname">SITES.<em class="replaceable"><code>distfile</code></em></code>
6611: to the list of URLs where the file
6612: <code class="filename"><em class="replaceable"><code>distfile</code></em></code>
6613: (including the suffix) can be found.</p>
6614: <pre class="programlisting">
6615: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
6616: DISTFILES+= foo-file.tar.gz
6617: SITES.foo-file.tar.gz= \
6618: http://www.somewhere.com/somehow/ \
6619: http://www.somewhereelse.com/mirror/somehow/
6620: </pre>
6621: <p>When actually fetching the distfiles, each item from
6622: <code class="varname">MASTER_SITES</code> or
6623: <code class="varname">SITES.*</code> gets the name of each distfile
6624: appended to it, without an intermediate slash. Therefore,
6625: all site values have to end with a slash or other separator
6626: character. This allows for example to set
6627: <code class="varname">MASTER_SITES</code> to a URL of a CGI script
6628: that gets the name of the distfile as a parameter. In this
6629: case, the definition would look like:</p>
6630: <pre class="programlisting">
6631: MASTER_SITES= http://www.example.com/download.cgi?file=
6632: </pre>
6633: <p>There are some predefined values for
6634: <code class="varname">MASTER_SITES</code>, which can be used in
6635: packages. The names of the variables should speak for
6636: themselves.</p>
6637: <pre class="programlisting">
6638: ${MASTER_SITE_APACHE}
6639: ${MASTER_SITE_BACKUP}
6640: ${MASTER_SITE_CYGWIN}
6641: ${MASTER_SITE_DEBIAN}
6642: ${MASTER_SITE_FREEBSD}
6643: ${MASTER_SITE_FREEBSD_LOCAL}
6644: ${MASTER_SITE_GENTOO}
6645: ${MASTER_SITE_GNOME}
6646: ${MASTER_SITE_GNU}
6647: ${MASTER_SITE_GNUSTEP}
6648: ${MASTER_SITE_IFARCHIVE}
6649: ${MASTER_SITE_KDE}
6650: ${MASTER_SITE_MOZILLA}
6651: ${MASTER_SITE_MYSQL}
6652: ${MASTER_SITE_OPENOFFICE}
6653: ${MASTER_SITE_PERL_CPAN}
6654: ${MASTER_SITE_PGSQL}
6655: ${MASTER_SITE_R_CRAN}
6656: ${MASTER_SITE_SOURCEFORGE}
6657: ${MASTER_SITE_SOURCEFORGE_JP}
6658: ${MASTER_SITE_SUNSITE}
6659: ${MASTER_SITE_SUSE}
6660: ${MASTER_SITE_TEX_CTAN}
6661: ${MASTER_SITE_XCONTRIB}
6662: ${MASTER_SITE_XEMACS}
6663: </pre>
6664: <p>Some explanations for the less self-explaining ones:
6665: <code class="varname">MASTER_SITE_BACKUP</code> contains backup sites
1.10 hubertf 6666: for packages that are maintained in <a class="ulink" 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
6667: package source distributions that are maintained in <a class="ulink" 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>
1.1 dsieger 6668: <p>If you choose one of these predefined sites, you may
6669: want to specify a subdirectory of that site. Since these
6670: macros may expand to more than one actual site, you
6671: <span class="emphasis"><em>must</em></span> use the following construct to
6672: specify a subdirectory:</p>
6673: <pre class="programlisting">
6674: MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
6675: MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
6676: </pre>
6677: <p>Note the trailing slash after the subdirectory
6678: name.</p>
6679: </div>
6680: <div class="sect2" lang="en">
6681: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 6682: <a name="build.fetch.how"></a>17.5.2. How are the files fetched?</h3></div></div></div>
1.1 dsieger 6683: <p>The <span class="emphasis"><em>fetch</em></span> phase makes sure that
6684: all the distfiles exist in a local directory
6685: (<code class="varname">DISTDIR</code>, which can be set by the pkgsrc
6686: user). If the files do not exist, they are fetched using
6687: commands of the form</p>
6688: <pre class="programlisting">
6689: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
6690: </pre>
6691: <p>where <code class="literal">${site}</code> varies through
6692: several possibilities in turn: first,
6693: <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the
6694: sites specified in either <code class="varname">SITES.file</code> if
6695: defined, else <code class="varname">MASTER_SITES</code> or
6696: <code class="varname">PATCH_SITES</code>, as applies, then finally the
6697: value of <code class="varname">MASTER_SITE_BACKUP</code>. The order of
6698: all except the first and the last can be optionally sorted
6699: by the user, via setting either
6700: <code class="varname">MASTER_SORT_RANDOM</code>, and
6701: <code class="varname">MASTER_SORT_AWK</code> or
6702: <code class="varname">MASTER_SORT_REGEX</code>.</p>
6703: <p>The distfiles mirror run by the NetBSD Foundation uses the
6704: <span class="emphasis"><em>mirror-distfiles</em></span> target to mirror the
6705: distfiles, if they are freely distributable. Packages setting
6706: <code class="varname">NO_SRC_ON_FTP</code> (usually to
6707: “<span class="quote">${RESTRICTED}</span>”) will not have their distfiles
6708: mirrored.</p>
6709: </div>
6710: </div>
6711: <div class="sect1" lang="en">
6712: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6713: <a name="build.checksum"></a>17.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
1.1 dsieger 6714: <p>After the distfile(s) are fetched, their checksum is
6715: generated and compared with the checksums stored in the
6716: distinfo file. If the checksums don't match, the build is
6717: aborted. This is to ensure the same distfile is used for
6718: building, and that the distfile wasn't changed, e.g. by some
6719: malign force, deliberately changed distfiles on the master
6720: distribution site or network lossage.</p>
6721: </div>
6722: <div class="sect1" lang="en">
6723: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6724: <a name="build.extract"></a>17.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
1.1 dsieger 6725: <p>When the distfiles are present on the local system, they
6726: need to be extracted, as they usually come in the form of some
6727: compressed archive format.</p>
6728: <p>By default, all <code class="varname">DISTFILES</code> are
6729: extracted. If you only need some of them, you can set the
6730: <code class="varname">EXTRACT_ONLY</code> variable to the list of those
6731: files.</p>
6732: <p>Extracting the files is usually done by a little
6733: program, <code class="filename">mk/extract/extract</code>, which
6734: already knows how to extract various archive formats, so most
6735: likely you will not need to change anything here. But if you
6736: need, the following variables may help you:</p>
6737: <div class="variablelist"><dl>
6738: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
6739: <dd><p>Use these variables to override the default
6740: options for an extract command, which are defined in
6741: <code class="filename">mk/extract/extract</code>.</p></dd>
6742: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
6743: <dd><p>This variable can be set to
1.14 ! jmcneill 6744: <code class="literal">bsdtar</code>, <code class="literal">gtar</code>, <code class="literal">nbtar</code>
! 6745: (which is the default value), <code class="literal">pax</code>, or an
1.1 dsieger 6746: absolute pathname pointing to the command with which tar
1.14 ! jmcneill 6747: archives should be extracted. It is preferred to choose bsdtar over gtar
! 6748: if NetBSD's pax-as-tar is not good enough.</p></dd>
1.1 dsieger 6749: </dl></div>
6750: <p>If the <code class="filename">extract</code> program doesn't
6751: serve your needs, you can also override the
6752: <code class="varname">EXTRACT_CMD</code> variable, which holds the
6753: command used for extracting the files. This command is
6754: executed in the <code class="filename">${WRKSRC}</code>
6755: directory. During execution of this command, the shell
6756: variable <code class="varname">extract_file</code> holds the absolute
6757: pathname of the file that is going to be extracted.</p>
6758: <p>And if that still does not suffice, you can override the
6759: <code class="varname">do-extract</code> target in the package
6760: Makefile.</p>
6761: </div>
6762: <div class="sect1" lang="en">
6763: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6764: <a name="build.patch"></a>17.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
1.1 dsieger 6765: <p>After extraction, all the patches named by the
6766: <code class="varname">PATCHFILES</code>, those present in the patches
6767: subdirectory of the package as well as in
6768: $LOCALPATCHES/$PKGPATH (e.g.
6769: <code class="filename">/usr/local/patches/graphics/png</code>) are
6770: applied. Patchfiles ending in <code class="filename">.Z</code> or
6771: <code class="filename">.gz</code> are uncompressed before they are
6772: applied, files ending in <code class="filename">.orig</code> or
6773: <code class="filename">.rej</code> are ignored. Any special options to
1.10 hubertf 6774: <a class="citerefentry" 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
6775: <code class="varname">PATCH_DIST_ARGS</code>. See <a class="xref" href="#components.patches" title="11.3. patches/*">Section 11.3, “patches/*”</a> for more details.</p>
6776: <p>By default <a class="citerefentry" 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
1.1 dsieger 6777: it fail if the patches apply with some lines of fuzz. Please
6778: fix (regen) the patches so that they apply cleanly. The
6779: rationale behind this is that patches that don't apply cleanly
6780: may end up being applied in the wrong place, and cause severe
6781: harm there.</p>
6782: </div>
6783: <div class="sect1" lang="en">
6784: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6785: <a name="build.tools"></a>17.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
1.10 hubertf 6786: <p>This is covered in <a class="xref" href="#tools" title="Chapter 18. Tools needed for building or running">Chapter 18, <i>Tools needed for building or running</i></a>.
1.1 dsieger 6787: </p>
6788: </div>
6789: <div class="sect1" lang="en">
6790: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6791: <a name="build.wrapper"></a>17.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
1.1 dsieger 6792: <p>This phase creates wrapper programs for the compilers and
6793: linkers. The following variables can be used to tweak the
6794: wrappers.</p>
6795: <div class="variablelist"><dl>
6796: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
6797: <dd><p>The command used to print progress
6798: messages. Does nothing by default. Set to
6799: <code class="literal">${ECHO}</code> to see the progress
6800: messages.</p></dd>
6801: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
6802: <dd><p>This variable can be set to
6803: <code class="literal">yes</code> (default) or <code class="literal">no</code>,
6804: depending on whether you want additional information in the
6805: wrapper log file.</p></dd>
6806: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
6807: <dd><p>This variable can be set to
6808: <code class="literal">yes</code> or <code class="literal">no</code>, depending
6809: on whether the wrapper should use its cache, which will
6810: improve the speed. The default value is
6811: <code class="literal">yes</code>, but is forced to
6812: <code class="literal">no</code> if the platform does not support
6813: it.</p></dd>
6814: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
6815: <dd><p>A list of reordering commands. A reordering
6816: command has the form
6817: <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
6818: It ensures that that
6819: <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code> occurs
6820: before <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
6821: </p></dd>
6822: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
6823: <dd><p>A list of transformation commands. [TODO:
6824: investigate further]</p></dd>
6825: </dl></div>
6826: </div>
6827: <div class="sect1" lang="en">
6828: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6829: <a name="build.configure"></a>17.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.1 dsieger 6830: <p>Most pieces of software need information on the header
6831: files, system calls, and library routines which are available
6832: on the platform they run on. The process of determining this
6833: information is known as configuration, and is usually
6834: automated. In most cases, a script is supplied with the
6835: distfiles, and its invocation results in generation of header
6836: files, Makefiles, etc.</p>
6837: <p>If the package contains a configure script, this can be
6838: invoked by setting <code class="varname">HAS_CONFIGURE</code> to
6839: “<span class="quote">yes</span>”. If the configure script is a GNU autoconf
6840: script, you should set <code class="varname">GNU_CONFIGURE</code> to
6841: “<span class="quote">yes</span>” instead. What happens in the
6842: <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
6843: <pre class="programlisting">
6844: .for d in ${CONFIGURE_DIRS}
6845: cd ${WRKSRC} \
6846: && cd ${d} \
6847: && env ${CONFIGURE_ENV} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
6848: .endfor
6849: </pre>
6850: <p><code class="varname">CONFIGURE_DIRS</code> (default:
6851: “<span class="quote">.</span>”) is a list of pathnames relative to
6852: <code class="varname">WRKSRC</code>. In each of these directories, the
6853: configure script is run with the environment
6854: <code class="varname">CONFIGURE_ENV</code> and arguments
6855: <code class="varname">CONFIGURE_ARGS</code>. The variables
6856: <code class="varname">CONFIGURE_ENV</code>,
6857: <code class="varname">CONFIGURE_SCRIPT</code> (default:
6858: “<span class="quote">./configure</span>”) and
6859: <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
6860: package.</p>
6861: <p>If the program uses an <code class="filename">Imakefile</code>
6862: for configuration, the appropriate steps can be invoked by
6863: setting <code class="varname">USE_IMAKE</code> to
6864: “<span class="quote">yes</span>”. (If you only want the package installed in
6865: <code class="varname">${X11PREFIX}</code> but xmkmf not being run, set
6866: <code class="varname">USE_X11BASE</code> instead.) You can add variables to
6867: xmkmf's environment by adding them to the
6868: <code class="varname">SCRIPTS_ENV</code> variable.</p>
1.11 rillig 6869: <p>If the program uses <code class="filename">cmake</code>
6870: for configuration, the appropriate steps can be invoked by
6871: setting <code class="varname">USE_CMAKE</code> to “<span class="quote">yes</span>”.
6872: You can add variables to cmake's environment by adding them to the
6873: <code class="varname">CONFIGURE_ENV</code> variable and arguments to cmake
6874: by adding them to the <code class="varname">CMAKE_ARGS</code> variable.
6875: The top directory argument is given by the
6876: <code class="varname">CMAKE_ARG_PATH</code> variable, that defaults to
6877: “<span class="quote">.</span>” (relative to <code class="varname">CONFIGURE_DIRS</code>)</p>
1.1 dsieger 6878: <p>If there is no configure step at all, set
6879: <code class="varname">NO_CONFIGURE</code> to “<span class="quote">yes</span>”.</p>
6880: </div>
6881: <div class="sect1" lang="en">
6882: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6883: <a name="build.build"></a>17.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.1 dsieger 6884: <p>For building a package, a rough equivalent of the
6885: following code is executed.</p>
6886: <pre class="programlisting">
6887: .for d in ${BUILD_DIRS}
6888: cd ${WRKSRC} \
6889: && cd ${d} \
6890: && env ${MAKE_ENV} \
6891: ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
6892: -f ${MAKE_FILE} \
6893: ${BUILD_TARGET}
6894: .endfor
6895: </pre>
6896: <p><code class="varname">BUILD_DIRS</code> (default:
6897: “<span class="quote">.</span>”) is a list of pathnames relative to
6898: <code class="varname">WRKSRC</code>. In each of these directories,
6899: <code class="varname">MAKE_PROGRAM</code> is run with the environment
6900: <code class="varname">MAKE_ENV</code> and arguments
6901: <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
6902: <code class="varname">MAKE_ENV</code>,
6903: <code class="varname">BUILD_MAKE_FLAGS</code>,
6904: <code class="varname">MAKE_FILE</code> and
6905: <code class="varname">BUILD_TARGET</code> may all be changed by the
6906: package.</p>
6907: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
6908: “<span class="quote">gmake</span>” if <code class="varname">USE_TOOLS</code> contains
6909: “<span class="quote">gmake</span>”, “<span class="quote">make</span>” otherwise. The
6910: default value of <code class="varname">MAKE_FILE</code> is
6911: “<span class="quote">Makefile</span>”, and <code class="varname">BUILD_TARGET</code>
6912: defaults to “<span class="quote">all</span>”.</p>
6913: <p>If there is no build step at all, set
6914: <code class="varname">NO_BUILD</code> to “<span class="quote">yes</span>”.</p>
6915: </div>
6916: <div class="sect1" lang="en">
6917: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6918: <a name="build.test"></a>17.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
1.1 dsieger 6919: <p>[TODO]</p>
6920: </div>
6921: <div class="sect1" lang="en">
6922: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 6923: <a name="build.install"></a>17.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.1 dsieger 6924: <p>Once the build stage has completed, the final step is to
6925: install the software in public directories, so users can
6926: access the programs and files.</p>
6927: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
6928: equivalent of the following code is executed. Additionally,
6929: before and after this code, much magic is performed to do
6930: consistency checks, registering the package, and so on.</p>
6931: <pre class="programlisting">
6932: .for d in ${INSTALL_DIRS}
6933: cd ${WRKSRC} \
6934: && cd ${d} \
6935: && env ${MAKE_ENV} \
6936: ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
6937: -f ${MAKE_FILE} \
6938: ${INSTALL_TARGET}
6939: .endfor
6940: </pre>
6941: <p>The variable's meanings are analogous to the ones in the
6942: <span class="emphasis"><em>build</em></span> phase.
6943: <code class="varname">INSTALL_DIRS</code> defaults to
6944: <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
6945: is “<span class="quote">install</span>” by default, plus
6946: “<span class="quote">install.man</span>” if <code class="varname">USE_IMAKE</code> is
6947: defined and <code class="varname">NO_INSTALL_MANPAGES</code> is not
6948: defined.</p>
6949: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
6950: variables are useful. They are all variations of the
1.10 hubertf 6951: <a class="citerefentry" 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
1.1 dsieger 6952: permissions preset. <code class="varname">INSTALL</code> is the plain
6953: install command. The specialized variants, together with their
6954: intended use, are:</p>
6955: <div class="variablelist"><dl>
6956: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
6957: <dd><p>directories that contain
6958: binaries</p></dd>
6959: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
6960: <dd><p>directories that contain
6961: scripts</p></dd>
6962: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
6963: <dd><p>directories that contain shared and static
6964: libraries</p></dd>
6965: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
6966: <dd><p>directories that contain data
6967: files</p></dd>
6968: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
6969: <dd><p>directories that contain man
6970: pages</p></dd>
6971: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
6972: <dd><p>binaries that can be stripped from debugging
6973: symbols</p></dd>
6974: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
6975: <dd><p>binaries that cannot be
6976: stripped</p></dd>
6977: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
6978: <dd><p>game
6979: binaries</p></dd>
6980: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
6981: <dd><p>shared and static
6982: libraries</p></dd>
6983: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
6984: <dd><p>data files</p></dd>
6985: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
6986: <dd><p>data files for
6987: games</p></dd>
6988: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
6989: <dd><p>man pages</p></dd>
6990: </dl></div>
6991: <p>Some other variables are:</p>
6992: <div class="variablelist"><dl>
6993: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
6994: <dd><p>A list of directories relative to
6995: <code class="varname">PREFIX</code> that are created by pkgsrc at the
6996: beginning of the <span class="emphasis"><em>install</em></span> phase.
6997: The package is supposed to create all needed directories itself
6998: before installing files to it and list all other directories here.
6999: </p></dd>
7000: </dl></div>
7001: <p>In the rare cases that a package shouldn't install anything,
7002: set <code class="varname">NO_INSTALL</code> to “<span class="quote">yes</span>”. This is
7003: mostly relevant for packages in the <code class="filename">regress</code>
7004: category.</p>
7005: </div>
7006: <div class="sect1" lang="en">
7007: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 7008: <a name="build.package"></a>17.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
1.1 dsieger 7009: <p>Once the install stage has completed, a binary package of
7010: the installed files can be built. These binary packages can be
7011: used for quick installation without previous compilation, e.g. by
1.10 hubertf 7012: the <span class="command"><strong>make bin-install</strong></span> or by using
7013: <span class="command"><strong>pkg_add</strong></span>.</p>
1.1 dsieger 7014: <p>By default, the binary packages are created in
7015: <code class="filename">${PACKAGES}/All</code> and symlinks are created in
7016: <code class="filename">${PACKAGES}/<em class="replaceable"><code>category</code></em></code>,
7017: one for each category in the <code class="varname">CATEGORIES</code>
7018: variable. <code class="varname">PACKAGES</code> defaults to
7019: <code class="filename">pkgsrc/packages</code>.</p>
7020: <p>If there should be no binary package, set
7021: <code class="varname">NO_PACKAGE</code> to “<span class="quote">yes</span>”.
7022: This should only be used in rare cases, like when a package
7023: definitely is only usable on the machine where it is built and even
7024: then, a binary package can be useful.</p>
7025: </div>
7026: <div class="sect1" lang="en">
7027: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 7028: <a name="build.clean"></a>17.16. Cleaning up</h2></div></div></div>
1.1 dsieger 7029: <p>Once you're finished with a package, you can clean the work
1.10 hubertf 7030: directory by running <span class="command"><strong>make clean</strong></span>. If you want
1.1 dsieger 7031: to clean the work directories of all dependencies too, use
1.10 hubertf 7032: <span class="command"><strong>make clean-depends</strong></span>.</p>
1.1 dsieger 7033: </div>
7034: <div class="sect1" lang="en">
7035: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 7036: <a name="build.helpful-targets"></a>17.17. Other helpful targets</h2></div></div></div>
1.1 dsieger 7037: <div class="variablelist"><dl>
7038: <dt><span class="term">pre/post-*</span></dt>
7039: <dd><p>For any of the main targets described in the
7040: previous section, two auxiliary targets exist with
7041: “<span class="quote">pre-</span>” and “<span class="quote">post-</span>” used as a
7042: prefix for the main target's name. These targets are
7043: invoked before and after the main target is called,
7044: allowing extra configuration or installation steps be
7045: performed from a package's Makefile, for example, which
7046: a program's configure script or install target
7047: omitted.</p></dd>
7048: <dt><span class="term">do-*</span></dt>
7049: <dd><p>Should one of the main targets do the wrong thing,
7050: and should there be no variable to fix this, you can
7051: redefine it with the do-* target. (Note that redefining
7052: the target itself instead of the do-* target is a bad
7053: idea, as the pre-* and post-* targets won't be called
7054: anymore, etc.) You will not usually need to do
7055: this.</p></dd>
7056: <dt><span class="term">reinstall</span></dt>
7057: <dd>
1.10 hubertf 7058: <p>If you did a <span class="command"><strong>make install</strong></span> and
1.1 dsieger 7059: you noticed some file was not installed properly, you
7060: can repeat the installation with this target, which will
7061: ignore the “<span class="quote">already installed</span>” flag.</p>
7062: <p>This is the default value of
7063: <code class="varname">DEPENDS_TARGET</code> except in the case of
1.10 hubertf 7064: <span class="command"><strong>make update</strong></span> and <span class="command"><strong>make
1.1 dsieger 7065: package</strong></span>, where the defaults are
7066: “<span class="quote">package</span>” and “<span class="quote">update</span>”,
7067: respectively.</p>
7068: </dd>
7069: <dt><span class="term">deinstall</span></dt>
7070: <dd>
1.10 hubertf 7071: <p>This target does a <a class="citerefentry" 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
1.1 dsieger 7072: current directory, effectively de-installing the
7073: package. The following variables can be used to tune the
7074: behaviour:</p>
7075: <div class="variablelist"><dl>
7076: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
1.10 hubertf 7077: <dd><p>Add a "-v" to the <a class="citerefentry" 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>
1.1 dsieger 7078: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
7079: <dd><p>Remove all packages that require (depend on)
7080: the given package. This can be used to remove any
7081: packages that may have been pulled in by a given
1.10 hubertf 7082: package, e.g. if <span class="command"><strong>make deinstall
1.1 dsieger 7083: DEINSTALLDEPENDS=1</strong></span> is done in
7084: <code class="filename">pkgsrc/x11/kde</code>, this is
7085: likely to remove whole KDE. Works by adding
1.10 hubertf 7086: “<span class="quote">-R</span>” to the <a class="citerefentry" 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>
1.1 dsieger 7087: command line.</p></dd>
7088: </dl></div>
7089: </dd>
7090: <dt><span class="term">bin-install</span></dt>
7091: <dd><p>Install a binary package from local disk and via FTP
7092: from a list of sites (see the
7093: <code class="varname">BINPKG_SITES</code> variable), and do a
1.10 hubertf 7094: <span class="command"><strong>make package</strong></span> if no binary package is
1.1 dsieger 7095: available anywhere. The arguments given to
1.10 hubertf 7096: <span class="command"><strong>pkg_add</strong></span> can be set via
1.1 dsieger 7097: <code class="varname">BIN_INSTALL_FLAGS</code> e.g., to do verbose
7098: operation, etc.</p></dd>
7099: <dt><span class="term">update</span></dt>
7100: <dd>
7101: <p>This target causes the current package to be
7102: updated to the latest version. The package and all
7103: depending packages first get de-installed, then current
7104: versions of the corresponding packages get compiled and
7105: installed. This is similar to manually noting which
7106: packages are currently installed, then performing a
1.10 hubertf 7107: series of <span class="command"><strong>make deinstall</strong></span> and
7108: <span class="command"><strong>make install</strong></span> (or whatever
1.1 dsieger 7109: <code class="varname">UPDATE_TARGET</code> is set to) for these
7110: packages.</p>
7111: <p>You can use the “<span class="quote">update</span>” target to
1.10 hubertf 7112: resume package updating in case a previous <span class="command"><strong>make
1.1 dsieger 7113: update</strong></span> was interrupted for some reason.
7114: However, in this case, make sure you don't call
1.10 hubertf 7115: <span class="command"><strong>make clean</strong></span> or otherwise remove the
1.1 dsieger 7116: list of dependent packages in <code class="varname">WRKDIR</code>.
7117: Otherwise, you lose the ability to automatically update
7118: the current package along with the dependent packages
7119: you have installed.</p>
1.10 hubertf 7120: <p>Resuming an interrupted <span class="command"><strong>make
1.1 dsieger 7121: update</strong></span> will only work as long as the package
7122: tree remains unchanged. If the source code for one of
7123: the packages to be updated has been changed, resuming
1.10 hubertf 7124: <span class="command"><strong>make update</strong></span> will most certainly
1.1 dsieger 7125: fail!</p>
7126: <p>The following variables can be used either on the
1.10 hubertf 7127: command line or in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> to
7128: alter the behaviour of <span class="command"><strong>make
1.1 dsieger 7129: update</strong></span>:</p>
7130: <div class="variablelist"><dl>
7131: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
7132: <dd><p>Install target to recursively use for the
7133: updated package and the dependent packages.
7134: Defaults to <code class="varname">DEPENDS_TARGET</code> if
7135: set, “<span class="quote">install</span>” otherwise for
1.10 hubertf 7136: <span class="command"><strong>make update</strong></span>. Other good
1.1 dsieger 7137: targets are “<span class="quote">package</span>” or
7138: “<span class="quote">bin-install</span>”. Do not set this to
7139: “<span class="quote">update</span>” or you will get stuck in an
7140: endless loop!</p></dd>
7141: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
7142: <dd><p>Don't clean up after updating. Useful if
7143: you want to leave the work sources of the updated
7144: packages around for inspection or other purposes.
7145: Be sure you eventually clean up the source tree
7146: (see the “<span class="quote">clean-update</span>” target below)
7147: or you may run into troubles with old source code
7148: still lying around on your next
1.10 hubertf 7149: <span class="command"><strong>make</strong></span> or <span class="command"><strong>make
1.1 dsieger 7150: update</strong></span>.</p></dd>
7151: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
7152: <dd><p>Deinstall each package before installing
7153: (making <code class="varname">DEPENDS_TARGET</code>). This
7154: may be necessary if the
7155: “<span class="quote">clean-update</span>” target (see below) was
1.10 hubertf 7156: called after interrupting a running <span class="command"><strong>make
1.1 dsieger 7157: update</strong></span>.</p></dd>
7158: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
7159: <dd><p>Allows you to disable recursion and hardcode
7160: the target for packages. The default is
7161: “<span class="quote">update</span>” for the update target,
7162: facilitating a recursive update of prerequisite
7163: packages. Only set
7164: <code class="varname">DEPENDS_TARGET</code> if you want to
7165: disable recursive updates. Use
7166: <code class="varname">UPDATE_TARGET</code> instead to just
7167: set a specific target for each package to be
1.10 hubertf 7168: installed during <span class="command"><strong>make update</strong></span>
1.1 dsieger 7169: (see above).</p></dd>
7170: </dl></div>
7171: </dd>
7172: <dt><span class="term">clean-update</span></dt>
7173: <dd>
7174: <p>Clean the source tree for all packages that would
1.10 hubertf 7175: get updated if <span class="command"><strong>make update</strong></span> was called
1.1 dsieger 7176: from the current directory. This target should not be
7177: used if the current package (or any of its depending
7178: packages) have already been de-installed (e.g., after
1.10 hubertf 7179: calling <span class="command"><strong>make update</strong></span>) or you may lose
1.1 dsieger 7180: some packages you intended to update. As a rule of
7181: thumb: only use this target <span class="emphasis"><em>before</em></span>
1.10 hubertf 7182: the first time you run <span class="command"><strong>make update</strong></span>
1.1 dsieger 7183: and only if you have a dirty package tree (e.g., if you
7184: used <code class="varname">NOCLEAN</code>).</p>
7185: <p>If you are unsure about whether your tree is
1.10 hubertf 7186: clean, you can either perform a <span class="command"><strong>make
1.1 dsieger 7187: clean</strong></span> at the top of the tree, or use the
7188: following sequence of commands from the directory of the
7189: package you want to update (<span class="emphasis"><em>before</em></span>
1.10 hubertf 7190: running <span class="command"><strong>make update</strong></span> for the first
1.1 dsieger 7191: time, otherwise you lose all the packages you wanted to
7192: update!):</p>
7193: <pre class="screen">
7194: <code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
7195: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
7196: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong>
7197: </pre>
7198: <p>The following variables can be used either on the
1.10 hubertf 7199: command line or in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> to alter the behaviour of
7200: <span class="command"><strong>make clean-update</strong></span>:</p>
1.1 dsieger 7201: <div class="variablelist"><dl>
7202: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
1.10 hubertf 7203: <dd><p>After <span class="command"><strong>make clean</strong></span>, do not
1.1 dsieger 7204: reconstruct the list of directories to update for
1.10 hubertf 7205: this package. Only use this if <span class="command"><strong>make
1.1 dsieger 7206: update</strong></span> successfully installed all
7207: packages you wanted to update. Normally, this is
1.10 hubertf 7208: done automatically on <span class="command"><strong>make
1.1 dsieger 7209: update</strong></span>, but may have been suppressed by
7210: the <code class="varname">NOCLEAN</code> variable (see
7211: above).</p></dd>
7212: </dl></div>
7213: </dd>
7214: <dt><span class="term">replace</span></dt>
7215: <dd>
7216: <p>Update the installation of the current package. This
7217: differs from update in that it does not replace dependent
7218: packages. You will need to install <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_tarup/README.html" target="_top"><code class="filename">pkgtools/pkg_tarup</code></a> for this
7219: target to work.</p>
7220: <p><span class="emphasis"><em>Be careful when using this
7221: target!</em></span> There are no guarantees that dependent
7222: packages will still work, in particular they will most
1.10 hubertf 7223: certainly break if you <span class="command"><strong>make replace</strong></span> a
1.1 dsieger 7224: library package whose shared library major version changed
7225: between your installed version and the new one. For this
7226: reason, this target is not officially supported and only
7227: recommended for advanced users.</p>
7228: </dd>
7229: <dt><span class="term">info</span></dt>
1.10 hubertf 7230: <dd><p>This target invokes <a class="citerefentry" 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.1 dsieger 7231: package. You can use this to check which version of a
7232: package is installed.</p></dd>
7233: <dt><span class="term">index</span></dt>
7234: <dd>
7235: <p>This is a top-level command, i.e. it should be used in
7236: the <code class="filename">pkgsrc</code> directory. It creates a
7237: database of all packages in the local pkgsrc tree, including
7238: dependencies, comment, maintainer, and some other useful
7239: information. Individual entries are created by running
1.10 hubertf 7240: <span class="command"><strong>make describe</strong></span> in the packages'
1.1 dsieger 7241: directories. This index file is saved as
7242: <code class="filename">pkgsrc/INDEX</code>. It can be displayed in
1.10 hubertf 7243: verbose format by running <span class="command"><strong>make
1.1 dsieger 7244: print-index</strong></span>. You can search in it with
1.10 hubertf 7245: <span class="command"><strong>make search
1.1 dsieger 7246: key=<em class="replaceable"><code>something</code></em></strong></span>. You can
7247: extract a list of all packages that depend on a particular
1.10 hubertf 7248: one by running <span class="command"><strong>make show-deps
1.1 dsieger 7249: PKG=<em class="replaceable"><code>somepackage</code></em></strong></span>.</p>
7250: <p>Running this command takes a very long time, some
7251: hours even on fast machines!</p>
7252: </dd>
7253: <dt><span class="term">readme</span></dt>
7254: <dd>
7255: <p>This target generates a
7256: <code class="filename">README.html</code> file, which can be
7257: viewed using a browser such as <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a> or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/links/README.html" target="_top"><code class="filename">www/links</code></a>. The generated files
7258: contain references to any packages which are in the
7259: <code class="varname">PACKAGES</code> directory on the local
7260: host. The generated files can be made to refer to URLs
7261: based on <code class="varname">FTP_PKG_URL_HOST</code> and
7262: <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I
7263: wanted to generate <code class="filename">README.html</code>
7264: files which pointed to binary packages on the local
7265: machine, in the directory
7266: <code class="filename">/usr/packages</code>, set
7267: <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
7268: <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
7269: <code class="varname">${PACKAGES}</code> directory and its
7270: subdirectories will be searched for all the binary
7271: packages.</p>
7272: <p>The target can be run at the toplevel or in category
7273: directories, in which case it descends recursively.</p>
7274: </dd>
7275: <dt><span class="term">readme-all</span></dt>
7276: <dd><p>This is a top-level command, run it in
7277: <code class="filename">pkgsrc</code>. Use this target to create a
7278: file <code class="filename">README-all.html</code> which contains a
7279: list of all packages currently available in the NetBSD
7280: Packages Collection, together with the category they belong
7281: to and a short description. This file is compiled from the
7282: <code class="filename">pkgsrc/*/README.html</code> files, so be sure
1.10 hubertf 7283: to run this <span class="emphasis"><em>after</em></span> a <span class="command"><strong>make
1.1 dsieger 7284: readme</strong></span>.</p></dd>
7285: <dt><span class="term">cdrom-readme</span></dt>
7286: <dd><p>This is very much the same as the
7287: “<span class="quote">readme</span>” target (see above), but is to be
7288: used when generating a pkgsrc tree to be written to a
7289: CD-ROM. This target also produces
7290: <code class="filename">README.html</code> files, and can be made
7291: to refer to URLs based on
7292: <code class="varname">CDROM_PKG_URL_HOST</code> and
7293: <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
7294: <dt><span class="term">show-distfiles</span></dt>
7295: <dd><p>This target shows which distfiles and patchfiles
7296: are needed to build the package
7297: (<code class="varname">ALLFILES</code>, which contains all
7298: <code class="varname">DISTFILES</code> and
7299: <code class="varname">PATCHFILES</code>, but not
7300: <code class="filename">patches/*</code>).</p></dd>
7301: <dt><span class="term">show-downlevel</span></dt>
7302: <dd><p>This target shows nothing if the package is not
7303: installed. If a version of this package is installed,
7304: but is not the version provided in this version of
7305: pkgsrc, then a warning message is displayed. This target
7306: can be used to show which of your installed packages are
7307: downlevel, and so the old versions can be deleted, and
7308: the current ones added.</p></dd>
7309: <dt><span class="term">show-pkgsrc-dir</span></dt>
7310: <dd><p>This target shows the directory in the pkgsrc
7311: hierarchy from which the package can be built and
7312: installed. This may not be the same directory as the one
7313: from which the package was installed. This target is
7314: intended to be used by people who may wish to upgrade
7315: many packages on a single host, and can be invoked from
7316: the top-level pkgsrc Makefile by using the
7317: “<span class="quote">show-host-specific-pkgs</span>” target.</p></dd>
7318: <dt><span class="term">show-installed-depends</span></dt>
7319: <dd><p>This target shows which installed packages match
7320: the current package's <code class="varname">DEPENDS</code>. Useful
7321: if out of date dependencies are causing build
7322: problems.</p></dd>
7323: <dt><span class="term">check-shlibs</span></dt>
7324: <dd><p>After a package is installed, check all its
7325: binaries and (on ELF platforms) shared libraries to see
7326: if they find the shared libs they need. Run by default
1.10 hubertf 7327: if <code class="varname">PKG_DEVELOPER</code> is set in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.</p></dd>
1.1 dsieger 7328: <dt><span class="term">print-PLIST</span></dt>
7329: <dd>
7330: <p>After a “<span class="quote">make install</span>” from a new or
7331: upgraded pkg, this prints out an attempt to generate a
1.10 hubertf 7332: new <code class="filename">PLIST</code> from a <span class="command"><strong>find
1.1 dsieger 7333: -newer work/.extract_done</strong></span>. An attempt is made
7334: to care for shared libs etc., but it is
7335: <span class="emphasis"><em>strongly</em></span> recommended to review the
7336: result before putting it into
7337: <code class="filename">PLIST</code>. On upgrades, it's useful to
7338: diff the output of this command against an already
7339: existing <code class="filename">PLIST</code> file.</p>
1.10 hubertf 7340: <p>If the package installs files via <a class="citerefentry" 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
1.1 dsieger 7341: other methods that don't update file access times, be
7342: sure to add these files manually to your
7343: <code class="filename">PLIST</code>, as the “<span class="quote">find
7344: -newer</span>” command used by this target won't catch
7345: them!</p>
1.10 hubertf 7346: <p>See <a class="xref" href="#print-PLIST" title="13.3. Tweaking output of make print-PLIST">Section 13.3, “Tweaking output of <span class="command"><strong>make print-PLIST</strong></span>”</a> for more
1.1 dsieger 7347: information on this target.</p>
7348: </dd>
7349: <dt><span class="term">bulk-package</span></dt>
7350: <dd>
7351: <p>Used to do bulk builds. If an appropriate binary
7352: package already exists, no action is taken. If not, this
7353: target will compile, install and package it (and its
7354: depends, if <code class="varname">PKG_DEPENDS</code> is set
1.10 hubertf 7355: properly. See <a class="xref" href="#binary.configuration" title="7.3.1. Configuration">Section 7.3.1, “Configuration”</a>).
1.1 dsieger 7356: After creating the binary package, the sources, the
7357: just-installed package and its required packages are
7358: removed, preserving free disk space.</p>
7359: <p><span class="emphasis"><em>Beware that this target may deinstall
7360: all packages installed on a system!</em></span></p>
7361: </dd>
7362: <dt><span class="term">bulk-install</span></dt>
7363: <dd>
7364: <p>Used during bulk-installs to install required
7365: packages. If an up-to-date binary package is available,
1.10 hubertf 7366: it will be installed via <a class="citerefentry" 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,
7367: <span class="command"><strong>make bulk-package</strong></span> will be executed,
1.1 dsieger 7368: but the installed binary won't be removed.</p>
7369: <p>A binary package is considered
7370: “<span class="quote">up-to-date</span>” to be installed via
1.10 hubertf 7371: <a class="citerefentry" 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>
1.1 dsieger 7372: <div class="itemizedlist"><ul type="disc">
7373: <li><p>None of the package's files
7374: (<code class="filename">Makefile</code>, ...) were modified
7375: since it was built.</p></li>
7376: <li><p>None of the package's required (binary)
7377: packages were modified since it was built.</p></li>
7378: </ul></div>
7379: <p><span class="emphasis"><em>Beware that this target may deinstall
7380: all packages installed on a system!</em></span></p>
7381: </dd>
7382: </dl></div>
7383: </div>
7384: </div>
7385: <div class="chapter" lang="en">
7386: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 7387: <a name="tools"></a>Chapter 18. Tools needed for building or running</h2></div></div></div>
1.1 dsieger 7388: <div class="toc">
7389: <p><b>Table of Contents</b></p>
7390: <dl>
1.6 rillig 7391: <dt><span class="sect1"><a href="#pkgsrc-tools">18.1. Tools for pkgsrc builds</a></span></dt>
7392: <dt><span class="sect1"><a href="#package-tools">18.2. Tools needed by packages</a></span></dt>
7393: <dt><span class="sect1"><a href="#platform-tools">18.3. Tools provided by platforms</a></span></dt>
7394: <dt><span class="sect1"><a href="#tools.questions">18.4. Questions regarding the tools</a></span></dt>
1.1 dsieger 7395: </dl>
7396: </div>
7397: <p>The <code class="varname">USE_TOOLS</code> definition is used both internally
7398: by pkgsrc and also for individual packages to define what commands
7399: are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
7400: or for later run-time of an installed packaged (such as
7401: <code class="varname">DEPENDS</code>).
7402: If the native system provides an adequate tool, then in many cases, a pkgsrc
7403: package will not be used.</p>
7404: <p>When building a package, the replacement tools are
7405: made available in a directory (as symlinks or wrapper scripts)
7406: that is early in the executable search path. Just like the buildlink
7407: system, this helps with consistent builds.</p>
7408: <p>A tool may be needed to help build a specific package. For example,
7409: perl, GNU make (gmake) or yacc may be needed.</p>
7410: <p>Also a tool may be needed, for example, because the native system's supplied
7411: tool may be inefficient for building a package with pkgsrc.
7412: For example, a package may need GNU awk, bison (instead of
7413: yacc) or a better sed.</p>
7414: <p>The tools used by a package can be listed by running
1.10 hubertf 7415: <span class="command"><strong>make show-tools</strong></span>.</p>
1.1 dsieger 7416: <div class="sect1" lang="en">
7417: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 7418: <a name="pkgsrc-tools"></a>18.1. Tools for pkgsrc builds</h2></div></div></div>
1.1 dsieger 7419: <p>The default set of tools used by pkgsrc is defined in
7420: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.10 hubertf 7421: such as: <span class="command"><strong>cat</strong></span>, <span class="command"><strong>awk</strong></span>,
7422: <span class="command"><strong>chmod</strong></span>, <span class="command"><strong>test</strong></span>, and so on.
1.1 dsieger 7423: These can be seen by running:
1.10 hubertf 7424: <span class="command"><strong>make show-var VARNAME=USE_TOOLS</strong></span>.</p>
1.1 dsieger 7425: <p>If a package needs a specific program to build
7426: then the <code class="varname">USE_TOOLS</code> variable can be used
7427: to define the tools needed.</p>
7428: </div>
7429: <div class="sect1" lang="en">
7430: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 7431: <a name="package-tools"></a>18.2. Tools needed by packages</h2></div></div></div>
1.1 dsieger 7432: <p>In the following examples, the :pkgsrc means to use the pkgsrc version
7433: and not the native version for a build dependency.
7434: And the :run means that it is used for a
7435: run-time dependencies also (and becomes a DEPENDS).
7436: The default is a build dependency which can be set with
7437: :build. (So in this example, it is the same as gmake:build
7438: and pkg-config:build.)</p>
7439: <pre class="programlisting">
7440: USE_TOOLS+= mktemp:pkgsrc
7441: USE_TOOLS+= gmake perl:run pkg-config
7442: </pre>
7443: <p>When using the tools framework, a
7444: <code class="varname">TOOLS_PATH.foo</code> variable is defined
7445: which contains the full path to the appropriate tool. For example,
7446: <code class="varname">TOOLS_PATH.bash</code> could be “<span class="quote">/bin/bash</span>”
7447: on Linux systems.</p>
7448: <p>If you always need a pkgsrc version of the
7449: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
7450: </p>
7451: </div>
7452: <div class="sect1" lang="en">
7453: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 7454: <a name="platform-tools"></a>18.3. Tools provided by platforms</h2></div></div></div>
1.1 dsieger 7455: <p>When improving or porting pkgsrc to a new platform, have a look
7456: at (or create) the corresponding platform specific make file fragment under
7457: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
7458: the name of the common tools. For example:</p>
7459: <pre class="programlisting">
7460: .if exists(/usr/bin/bzcat)
7461: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
7462: .elif exists(/usr/bin/bzip2)
7463: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
7464: .endif
7465:
7466: TOOLS_PLATFORM.true?= true # shell builtin
7467: </pre>
7468: </div>
7469: <div class="sect1" lang="en">
7470: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 7471: <a name="tools.questions"></a>18.4. Questions regarding the tools</h2></div></div></div>
1.1 dsieger 7472: <div class="qandaset">
7473: <dl>
1.6 rillig 7474: <dt>18.4.1. <a href="#tools.new">How do I add a new tool?</a>
1.1 dsieger 7475: </dt>
1.6 rillig 7476: <dt>18.4.2. <a href="#tools.listall">How do I get a list of all available
1.1 dsieger 7477: tools?</a>
7478: </dt>
1.6 rillig 7479: <dt>18.4.3. <a href="#tools.used">How can I get a list of all the tools that a
1.1 dsieger 7480: package is using while being built? I want to know whether it
7481: uses sed or not.</a>
7482: </dt>
7483: </dl>
7484: <table border="0" summary="Q and A Set">
7485: <col align="left" width="1%">
7486: <tbody>
7487: <tr class="question">
7488: <td align="left" valign="top">
1.14 ! jmcneill 7489: <a name="tools.new"></a><a name="id1168230246568"></a><p><b>18.4.1.</b></p>
1.1 dsieger 7490: </td>
7491: <td align="left" valign="top"><p>How do I add a new tool?</p></td>
7492: </tr>
7493: <tr class="answer">
7494: <td align="left" valign="top"></td>
7495: <td align="left" valign="top"><p>TODO</p></td>
7496: </tr>
7497: <tr class="question">
7498: <td align="left" valign="top">
1.14 ! jmcneill 7499: <a name="tools.listall"></a><a name="id1168230246577"></a><p><b>18.4.2.</b></p>
1.1 dsieger 7500: </td>
7501: <td align="left" valign="top"><p>How do I get a list of all available
7502: tools?</p></td>
7503: </tr>
7504: <tr class="answer">
7505: <td align="left" valign="top"></td>
7506: <td align="left" valign="top"><p>TODO</p></td>
7507: </tr>
7508: <tr class="question">
7509: <td align="left" valign="top">
1.14 ! jmcneill 7510: <a name="tools.used"></a><a name="id1168230246585"></a><p><b>18.4.3.</b></p>
1.1 dsieger 7511: </td>
7512: <td align="left" valign="top"><p>How can I get a list of all the tools that a
7513: package is using while being built? I want to know whether it
7514: uses sed or not.</p></td>
7515: </tr>
7516: <tr class="answer">
7517: <td align="left" valign="top"></td>
7518: <td align="left" valign="top"><p>Currently, you can't. (TODO: But I want to be able
7519: to do it.)</p></td>
7520: </tr>
7521: </tbody>
7522: </table>
7523: </div>
7524: </div>
7525: </div>
7526: <div class="chapter" lang="en">
7527: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 7528: <a name="fixes"></a>Chapter 19. Making your package work</h2></div></div></div>
1.1 dsieger 7529: <div class="toc">
7530: <p><b>Table of Contents</b></p>
7531: <dl>
1.6 rillig 7532: <dt><span class="sect1"><a href="#general-operation">19.1. General operation</a></span></dt>
1.1 dsieger 7533: <dd><dl>
1.6 rillig 7534: <dt><span class="sect2"><a href="#portability-of-packages">19.1.1. Portability of packages</a></span></dt>
7535: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">19.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
7536: <dt><span class="sect2"><a href="#user-interaction">19.1.3. User interaction</a></span></dt>
7537: <dt><span class="sect2"><a href="#handling-licenses">19.1.4. Handling licenses</a></span></dt>
7538: <dt><span class="sect2"><a href="#restricted-packages">19.1.5. Restricted packages</a></span></dt>
7539: <dt><span class="sect2"><a href="#dependencies">19.1.6. Handling dependencies</a></span></dt>
7540: <dt><span class="sect2"><a href="#conflicts">19.1.7. Handling conflicts with other packages</a></span></dt>
7541: <dt><span class="sect2"><a href="#not-building-packages">19.1.8. Packages that cannot or should not be built</a></span></dt>
7542: <dt><span class="sect2"><a href="#undeletable-packages">19.1.9. Packages which should not be deleted, once installed</a></span></dt>
7543: <dt><span class="sect2"><a href="#security-handling">19.1.10. Handling packages with security problems</a></span></dt>
7544: <dt><span class="sect2"><a href="#bumping-pkgrevision">19.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
7545: <dt><span class="sect2"><a href="#fixes.subst">19.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
7546: </dl></dd>
7547: <dt><span class="sect1"><a href="#fixes.fetch">19.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
7548: <dd><dl>
7549: <dt><span class="sect2"><a href="#no-plain-download">19.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
7550: <dt><span class="sect2"><a href="#modified-distfiles-same-name">19.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
7551: </dl></dd>
7552: <dt><span class="sect1"><a href="#fixes.configure">19.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
7553: <dd><dl>
7554: <dt><span class="sect2"><a href="#fixes.libtool">19.3.1. Shared libraries - libtool</a></span></dt>
7555: <dt><span class="sect2"><a href="#using-libtool">19.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
7556: <dt><span class="sect2"><a href="#autoconf-automake">19.3.3. GNU Autoconf/Automake</a></span></dt>
7557: </dl></dd>
7558: <dt><span class="sect1"><a href="#programming-languages">19.4. Programming languages</a></span></dt>
7559: <dd><dl>
7560: <dt><span class="sect2"><a href="#basic-programming-languages">19.4.1. C, C++, and Fortran</a></span></dt>
7561: <dt><span class="sect2"><a href="#java-programming-language">19.4.2. Java</a></span></dt>
7562: <dt><span class="sect2"><a href="#perl-scripts">19.4.3. Packages containing perl scripts</a></span></dt>
7563: <dt><span class="sect2"><a href="#other-programming-languages">19.4.4. Other programming languages</a></span></dt>
7564: </dl></dd>
7565: <dt><span class="sect1"><a href="#fixes.build">19.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
7566: <dd><dl>
7567: <dt><span class="sect2"><a href="#fixes.build.cpp">19.5.1. Compiling C and C++ code conditionally</a></span></dt>
7568: <dt><span class="sect2"><a href="#compiler-bugs">19.5.2. How to handle compiler bugs</a></span></dt>
7569: <dt><span class="sect2"><a href="#undefined-reference">19.5.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
7570: <dt><span class="sect2"><a href="#out-of-memory">19.5.4. Running out of memory</a></span></dt>
7571: </dl></dd>
7572: <dt><span class="sect1"><a href="#fixes.install">19.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
7573: <dd><dl>
7574: <dt><span class="sect2"><a href="#install-scripts">19.6.1. Creating needed directories</a></span></dt>
7575: <dt><span class="sect2"><a href="#where-to-install-documentation">19.6.2. Where to install documentation</a></span></dt>
7576: <dt><span class="sect2"><a href="#installing-score-files">19.6.3. Installing highscore files</a></span></dt>
7577: <dt><span class="sect2"><a href="#destdir-support">19.6.4. Adding DESTDIR support to packages</a></span></dt>
7578: <dt><span class="sect2"><a href="#hardcoded-paths">19.6.5. Packages with hardcoded paths to other interpreters</a></span></dt>
7579: <dt><span class="sect2"><a href="#perl-modules">19.6.6. Packages installing perl modules</a></span></dt>
7580: <dt><span class="sect2"><a href="#faq.info-files">19.6.7. Packages installing info files</a></span></dt>
7581: <dt><span class="sect2"><a href="#manpages">19.6.8. Packages installing man pages</a></span></dt>
1.7 rillig 7582: <dt><span class="sect2"><a href="#gconf-data-files">19.6.9. Packages installing GConf data files</a></span></dt>
1.6 rillig 7583: <dt><span class="sect2"><a href="#scrollkeeper-data-files">19.6.10. Packages installing scrollkeeper data files</a></span></dt>
7584: <dt><span class="sect2"><a href="#x11-fonts">19.6.11. Packages installing X11 fonts</a></span></dt>
7585: <dt><span class="sect2"><a href="#gtk2-modules">19.6.12. Packages installing GTK2 modules</a></span></dt>
7586: <dt><span class="sect2"><a href="#sgml-xml-data">19.6.13. Packages installing SGML or XML data</a></span></dt>
7587: <dt><span class="sect2"><a href="#mime-database">19.6.14. Packages installing extensions to the MIME database</a></span></dt>
7588: <dt><span class="sect2"><a href="#intltool">19.6.15. Packages using intltool</a></span></dt>
7589: <dt><span class="sect2"><a href="#startup-scripts">19.6.16. Packages installing startup scripts</a></span></dt>
7590: <dt><span class="sect2"><a href="#tex-packages">19.6.17. Packages installing TeX modules</a></span></dt>
7591: <dt><span class="sect2"><a href="#emulation-packages">19.6.18. Packages supporting running binaries in
1.1 dsieger 7592: emulation</a></span></dt>
1.6 rillig 7593: <dt><span class="sect2"><a href="#hicolor-theme">19.6.19. Packages installing hicolor theme icons</a></span></dt>
7594: <dt><span class="sect2"><a href="#desktop-files">19.6.20. Packages installing desktop files</a></span></dt>
1.1 dsieger 7595: </dl></dd>
1.6 rillig 7596: <dt><span class="sect1"><a href="#punting">19.7. Marking packages as having problems</a></span></dt>
1.1 dsieger 7597: </dl>
7598: </div>
7599: <div class="sect1" lang="en">
7600: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 7601: <a name="general-operation"></a>19.1. General operation</h2></div></div></div>
1.1 dsieger 7602: <div class="sect2" lang="en">
7603: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 7604: <a name="portability-of-packages"></a>19.1.1. Portability of packages</h3></div></div></div>
1.1 dsieger 7605: <p>One appealing feature of pkgsrc is that it runs on many
7606: different platforms. As a result, it is important to ensure,
7607: where possible, that packages in pkgsrc are portable. This
7608: chapter mentions some particular details you should pay
7609: attention to while working on pkgsrc.</p>
7610: </div>
7611: <div class="sect2" lang="en">
7612: <div class="titlepage"><div><div><h3 class="title">
1.10 hubertf 7613: <a name="pulling-vars-from-etc-mk.conf"></a>19.1.2. How to pull in user-settable variables from <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>
1.1 dsieger 7614: </h3></div></div></div>
7615: <p>The pkgsrc user can configure pkgsrc by overriding several
7616: variables in the file pointed to by <code class="varname">MAKECONF</code>,
1.10 hubertf 7617: which is <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> by default. When you
1.1 dsieger 7618: want to use those variables in the preprocessor directives of
1.10 hubertf 7619: <a class="citerefentry" 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
1.1 dsieger 7620: <code class="literal">.for</code>), you need to include the file
7621: <code class="filename">../../mk/bsd.prefs.mk</code> before, which in turn
7622: loads the user preferences.</p>
7623: <p>But note that some variables may not be completely defined
7624: after <code class="filename">../../mk/bsd.prefs.mk</code> has been
7625: included, as they may contain references to variables that are
7626: not yet defined. In shell commands this is no problem, since
7627: variables are actually macros, which are only expanded when they
7628: are used. But in the preprocessor directives mentioned above and
7629: in dependency lines (of the form <code class="literal">target:
7630: dependencies</code>) the variables are expanded at load
7631: time.</p>
7632: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7633: <h3 class="title">Note</h3>
7634: <p>Currently there is no exhaustive list of all
7635: variables that tells you whether they can be used at load time
7636: or only at run time, but it is in preparation.</p>
7637: </div>
7638: </div>
7639: <div class="sect2" lang="en">
7640: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 7641: <a name="user-interaction"></a>19.1.3. User interaction</h3></div></div></div>
1.1 dsieger 7642: <p>Occasionally, packages require interaction from the user,
7643: and this can be in a number of ways:</p>
7644: <div class="itemizedlist"><ul type="disc">
7645: <li><p>When fetching the distfiles, some packages require user
7646: interaction such as entering username/password or accepting a
7647: license on a web page.</p></li>
7648: <li><p>When extracting the distfiles, some packages may ask for
7649: passwords.</p></li>
7650: <li><p>help to configure the package before it is built</p></li>
7651: <li><p>help during the build process</p></li>
7652: <li><p>help during the installation of a package</p></li>
7653: </ul></div>
7654: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is
7655: provided to notify the pkgsrc mechanism of an interactive stage
7656: which will be needed, and this should be set in the package's
7657: <code class="filename">Makefile</code>, e.g.:</p>
7658: <pre class="programlisting">
7659: INTERACTIVE_STAGE= build
7660: </pre>
7661: <p>Multiple interactive stages can be specified:</p>
7662: <pre class="programlisting">
7663: INTERACTIVE_STAGE= configure install
7664: </pre>
7665: <p>The user can then decide to skip this package by setting the
7666: <code class="varname">BATCH</code> variable.</p>
7667: </div>
7668: <div class="sect2" lang="en">
7669: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 7670: <a name="handling-licenses"></a>19.1.4. Handling licenses</h3></div></div></div>
1.1 dsieger 7671: <p>Authors of software can choose the licence under which
7672: software can be copied. This is due to copyright law, and reasons
7673: for license choices are outside the scope of pkgsrc. The pkgsrc
7674: system recognizes that there are a number of licenses which some
7675: users may find objectionable or difficult or impossible to comply
7676: with. The Free Software Foundation has declared some licenses
7677: "Free", and the Open Source Initiative has a definition of "Open
7678: Source". The pkgsrc system, as a policy choice, does not label
7679: packages which have licenses that are Free or Open Source.
7680: However, packages without a license meeting either of those tests
7681: are labeled with a license tag denoting the license. Note that a
7682: package with no license to copy trivially does not meet either the
7683: Free or Open Source test.</p>
7684: <p>For packages which are not Free or Open Source, pkgsrc will
7685: not build the package unless the user has indicated to pkgsrc that
7686: packages with that particular license may be built. Note that
7687: this documentation avoids the term "accepted the license". The
7688: pkgsrc system is merely providing a mechanism to avoid
7689: accidentally building a package with a non-free license;
7690: judgement and responsibility remain with the user. (Installation
7691: of binary packages are not currently subject to this mechanism;
7692: this is a bug.)</p>
7693: <p>One might want to only install packages with a BSD license,
7694: or the GPL, and not the other. The pkgsrc license tag mechanism
7695: does not provide a way to do this. It might be possible to put in
7696: tags for free licenses, and have a default
7697: <code class="varname">ACCEPTABLE_LICENSES</code> variable value, but this is
7698: widely viewed as having a very poor ratio of benefit to
7699: work.</p>
7700: <p>The license tag mechanism is intended to address
7701: copyright-related issues surrounding building, installing and
7702: using a package, and not to address redistribution issues (see
7703: <code class="varname">RESTRICTED</code> and
7704: <code class="varname">NO_SRC_ON_FTP</code>, etc.). However, the above
7705: definition of licenses for which tags are not needed implies
7706: that packages with redistribution restrictions should have
7707: tags, because Free or Open Source programs do not have
7708: redistribution restrictions.</p>
7709: <p>Denoting that a package may be copied according to a
7710: particular license is done by placing the license in
7711: <code class="filename">pkgsrc/licenses</code> and setting the
7712: <code class="varname">LICENSE</code> variable to a string identifying the
7713: license, e.g. in <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>:</p>
7714: <pre class="programlisting">
7715: LICENSE= xv-license
7716: </pre>
7717: <p>When trying to build, the user will get a notice that the
7718: package is covered by a license which has not been placed in the
7719: <code class="varname">ACCEPTABLE_LICENSES</code> variable:</p>
7720: <pre class="programlisting">
7721: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
7722: ===> xv-3.10anb9 has an unacceptable license: xv-license.
7723: ===> To view the license, enter "/usr/bin/make show-license".
7724: ===> To indicate acceptance, add this line to your /etc/mk.conf:
7725: ===> ACCEPTABLE_LICENSES+=xv-license
7726: *** Error code 1
7727: </pre>
1.10 hubertf 7728: <p>The license can be viewed with <span class="command"><strong>make
1.1 dsieger 7729: show-license</strong></span>, and if the user so chooses, the line
1.10 hubertf 7730: printed above can be added to <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> to
1.1 dsieger 7731: convey to pkgsrc that it should not in the future fail because of
7732: that license:</p>
7733: <pre class="programlisting">
7734: ACCEPTABLE_LICENSES+=xv-license
7735: </pre>
7736: <p>When adding a package with a new license, the license text
7737: should be added to <code class="filename">pkgsrc/licenses</code> for
7738: displaying. A list of known licenses can be seen in this
7739: directory.</p>
7740: <p>When the license changes (in a way other than formatting),
7741: please make sure that the new license has a different name (e.g.,
7742: append the version number if it exists, or the date). Just
7743: because a user told pkgsrc to build programs under a previous
7744: version of a license does not mean that pkgsrc should build
7745: programs under the new licenses. The higher-level point is that
7746: pkgsrc does not evaluate licenses for reasonableness; the only
7747: test is a mechanistic test of whether a particular text has been
7748: approved by either of two bodies.</p>
7749: <p>The use of <code class="varname">LICENSE=shareware</code>,
7750: <code class="varname">LICENSE=no-commercial-use</code>, and similar language
7751: is deprecated because it does not crisply refer to a particular
7752: license text. Another problem with such usage is that it does not
7753: enable a user to tell pkgsrc to proceed for a single package
7754: without also telling pkgsrc to proceed for all packages with that
7755: tag.</p>
7756: </div>
7757: <div class="sect2" lang="en">
7758: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 7759: <a name="restricted-packages"></a>19.1.5. Restricted packages</h3></div></div></div>
1.1 dsieger 7760: <p>Some licenses restrict how software may be re-distributed.
7761: Because a license tag is required unless the package is Free or
7762: Open Source, all packages with restrictions should have license
7763: tags. By declaring the restrictions, package tools can
7764: automatically refrain from e.g. placing binary packages on FTP
7765: sites.</p>
7766: <p>There are four restrictions that may be encoded, which are
7767: the cross product of sources (distfiles) and binaries not being
7768: placed on FTP sites and CD-ROMs. Because this is rarely the exact
7769: language in any license, and because non-Free licenses tend to be
7770: different from each other, pkgsrc adopts a definition of FTP and
7771: CD-ROM. Pkgsrc uses "FTP" to mean that the source or binary file
7772: should not be made available over the Internet at no charge.
7773: Pkgsrc uses "CD-ROM" to mean that the source or binary may not be
7774: made available on some kind of media, together with other source
7775: and binary packages, and which is sold for a distribution charge.
7776: </p>
7777: <p>In order to encode these restrictions, the package system
7778: defines five make variables that can be set to note these
7779: restrictions:</p>
7780: <div class="itemizedlist"><ul type="disc">
7781: <li>
7782: <p><code class="varname">RESTRICTED</code></p>
7783: <p>This variable should be set whenever a restriction
7784: exists (regardless of its kind). Set this variable to a
7785: string containing the reason for the restriction. It should
7786: be understood that those wanting to understand the restriction
7787: will have to read the license, and perhaps seek advice of
7788: counsel.</p>
7789: </li>
7790: <li>
7791: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
7792: <p>Binaries may not be placed on CD-ROM containing other
7793: binary packages, for which a distribution charge may be made.
7794: In this case, set this variable to
7795: <code class="varname">${RESTRICTED}</code>.</p>
7796: </li>
7797: <li>
7798: <p><code class="varname">NO_BIN_ON_FTP</code></p>
7799: <p>Binaries may not made available on the Internet without
7800: charge. In this case, set this variable to
7801: <code class="varname">${RESTRICTED}</code>. If this variable is set,
7802: binary packages will not be included on ftp.NetBSD.org.</p>
7803: </li>
7804: <li>
7805: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
7806: <p>Distfiles may not be placed on CD-ROM, together with
7807: other distfiles, for which a fee may be charged. In this
7808: case, set this variable to <code class="varname">${RESTRICTED}</code>.
7809: </p>
7810: </li>
7811: <li>
7812: <p><code class="varname">NO_SRC_ON_FTP</code></p>
7813: <p>Distfiles may not made available via FTP at no charge.
7814: In this case, set this variable to
7815: <code class="varname">${RESTRICTED}</code>. If this variable is set,
7816: the distfile(s) will not be mirrored on ftp.NetBSD.org.</p>
7817: </li>
7818: </ul></div>
7819: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
7820: <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
7821: generic make variables to denote restrictions is deprecated,
7822: because they unconditionally prevent users from generating
7823: binary packages!</p>
7824: </div>
7825: <div class="sect2" lang="en">
7826: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 7827: <a name="dependencies"></a>19.1.6. Handling dependencies</h3></div></div></div>
1.1 dsieger 7828: <p>Your package may depend on some other package being present
7829: - and there are various ways of expressing this dependency.
7830: pkgsrc supports the <code class="varname">BUILD_DEPENDS</code> and
7831: <code class="varname">DEPENDS</code> definitions, the
7832: <code class="varname">USE_TOOLS</code> definition, as well as dependencies
7833: via <code class="filename">buildlink3.mk</code>, which is the preferred way
7834: to handle dependencies, and which uses the variables named above.
1.10 hubertf 7835: See <a class="xref" href="#buildlink" title="Chapter 14. Buildlink methodology">Chapter 14, <i>Buildlink methodology</i></a> for more information.</p>
1.1 dsieger 7836: <p>The basic difference between the two variables is as
7837: follows: The <code class="varname">DEPENDS</code> definition registers
7838: that pre-requisite in the binary package so it will be pulled in
7839: when the binary package is later installed, whilst the
7840: <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
7841: dependency that is only needed for building the package.</p>
7842: <p>This means that if you only need a package present whilst
7843: you are building, it should be noted as a
7844: <code class="varname">BUILD_DEPENDS</code>.</p>
7845: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
7846: <code class="varname">DEPENDS</code> definition is:</p>
7847: <pre class="programlisting">
7848: <pre-req-package-name>:../../<category>/<pre-req-package>
7849: </pre>
7850: <p>Please note that the “<span class="quote">pre-req-package-name</span>”
7851: may include any of the wildcard version numbers recognized by
1.10 hubertf 7852: <a class="citerefentry" 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.1 dsieger 7853: <div class="orderedlist"><ol type="1">
7854: <li>
7855: <p>If your package needs another package's binaries or
7856: libraries to build or run, and if that package has a
7857: <code class="filename">buildlink3.mk</code> file available, use it:</p>
7858: <pre class="programlisting">
7859: .include "../../graphics/jpeg/buildlink3.mk"
7860: </pre>
7861: </li>
7862: <li>
7863: <p>If your package needs to use another package to build
7864: itself and there is no <code class="filename">buildlink3.mk</code>
7865: file available, use the <code class="varname">BUILD_DEPENDS</code>
7866: definition:</p>
7867: <pre class="programlisting">
7868: BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
7869: </pre>
7870: </li>
7871: <li>
7872: <p>If your package needs a library with which to link and
7873: again there is no <code class="filename">buildlink3.mk</code> file
7874: available, this is specified using the
7875: <code class="varname">DEPENDS</code> definition. For example:</p>
7876: <pre class="programlisting">
7877: DEPENDS+= xpm-3.4j:../../graphics/xpm
7878: </pre>
1.9 rillig 7879: <p>You can also use wildcards in package dependencies:</p>
1.1 dsieger 7880: <pre class="programlisting">
7881: DEPENDS+= xpm-[0-9]*:../../graphics/xpm
7882: </pre>
7883: <p>Note that such wildcard dependencies are retained when
7884: creating binary packages. The dependency is checked when
7885: installing the binary package and any package which matches
7886: the pattern will be used. Wildcard dependencies should be
7887: used with care.</p>
7888: <p>The “<span class="quote">-[0-9]*</span>” should be used instead of
7889: “<span class="quote">-*</span>” to avoid potentially ambiguous matches
7890: such as “<span class="quote">tk-postgresql</span>” matching a
7891: “<span class="quote">tk-*</span>” <code class="varname">DEPENDS</code>.</p>
7892: <p>Wildcards can also be used to specify that a package
7893: will only build against a certain minimum version of a
7894: pre-requisite:</p>
7895: <pre class="programlisting">
7896: DEPENDS+= tiff>=3.5.4:../../graphics/tiff
7897: </pre>
7898: <p>This means that the package will build against version
7899: 3.5.4 of the tiff library or newer. Such a dependency may
7900: be warranted if, for example, the API of the library has
7901: changed with version 3.5.4 and a package would not compile
7902: against an earlier version of tiff.</p>
7903: <p>Please note that such dependencies should only be
7904: updated if a package requires a newer pre-requisite, but
7905: not to denote recommendations such as
7906: ABI changes that do not prevent a package from building
7907: correctly. Such recommendations can be expressed using
7908: <code class="varname">ABI_DEPENDS</code>:</p>
7909: <pre class="programlisting">
7910: ABI_DEPENDS+= tiff>=3.6.1:../../graphics/tiff
7911: </pre>
7912: <p>In addition to the above <code class="varname">DEPENDS</code>
7913: line, this denotes that while a package will build against
7914: tiff>=3.5.4, at least version 3.6.1 is recommended.
7915: <code class="varname">ABI_DEPENDS</code> entries will be turned into
7916: dependencies unless explicitly ignored (in which case a
7917: warning will be printed).</p>
7918: <p>To ignore these ABI dependency recommendations and just
7919: use the required <code class="varname">DEPENDS</code>, set
7920: <code class="varname">USE_ABI_DEPENDS=NO</code>. This may make
7921: it easier and faster to update packages built using pkgsrc,
7922: since older compatible dependencies can continue to be
7923: used. This is useful for people who watch their rebuilds
7924: very carefully; it is not very good as a general-purpose
7925: hammer. If you use it, you need to be mindful of possible
7926: ABI changes, including those from the underlying OS.</p>
7927: <p>Packages that are built with recommendations ignored
7928: may not be uploaded to ftp.NetBSD.org by developers and
7929: should not be used across different systems that may have
7930: different versions of binary packages installed.</p>
7931: <p>For security fixes, please update the package
1.10 hubertf 7932: vulnerabilities file. See <a class="xref" href="#security-handling" title="19.1.10. Handling packages with security problems">Section 19.1.10, “Handling packages with security problems”</a> for more
1.1 dsieger 7933: information.</p>
7934: </li>
7935: <li>
7936: <p>If your package needs some executable to be able to run
7937: correctly and if there's no
7938: <code class="filename">buildlink3.mk</code> file, this is specified
7939: using the <code class="varname">DEPENDS</code> variable. The
7940: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/print/lyx/README.html" target="_top"><code class="filename">print/lyx</code></a> package needs to
7941: be able to execute the latex binary from the teTeX package
7942: when it runs, and that is specified:</p>
7943: <pre class="programlisting">
7944: DEPENDS+= teTeX-[0-9]*:../../print/teTeX
7945: </pre>
7946: <p>The comment about wildcard dependencies from previous
7947: paragraph applies here, too.</p>
7948: </li>
7949: </ol></div>
7950: <p>If your package needs files from another package to build,
7951: add the relevant distribution files to
7952: <code class="varname">DISTFILES</code>, so they will be extracted
7953: automatically. See the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/print/ghostscript/README.html" target="_top"><code class="filename">print/ghostscript</code></a> package for an example.
7954: (It relies on the jpeg sources being present in source form
7955: during the build.)</p>
7956: </div>
7957: <div class="sect2" lang="en">
7958: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 7959: <a name="conflicts"></a>19.1.7. Handling conflicts with other packages</h3></div></div></div>
1.1 dsieger 7960: <p>Your package may conflict with other packages a user might
7961: already have installed on his system, e.g. if your package
7962: installs the same set of files as another package in the pkgsrc
7963: tree.</p>
7964: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
7965: space-separated list of packages (including version string) your
7966: package conflicts with.</p>
7967: <p>For example, <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/Xaw3d/README.html" target="_top"><code class="filename">x11/Xaw3d</code></a>
7968: and <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/x11/Xaw-Xpm/README.html" target="_top"><code class="filename">x11/Xaw-Xpm</code></a>
7969: install the same shared library, thus you set in
7970: <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
7971: <pre class="programlisting">
7972: CONFLICTS= Xaw-Xpm-[0-9]*
7973: </pre>
7974: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:</p>
7975: <pre class="programlisting">
7976: CONFLICTS= Xaw3d-[0-9]*
7977: </pre>
7978: <p>Packages will automatically conflict with other packages
7979: with the name prefix and a different version
7980: string. “<span class="quote">Xaw3d-1.5</span>” e.g. will automatically
7981: conflict with the older version “<span class="quote">Xaw3d-1.3</span>”.</p>
7982: </div>
7983: <div class="sect2" lang="en">
7984: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 7985: <a name="not-building-packages"></a>19.1.8. Packages that cannot or should not be built</h3></div></div></div>
1.1 dsieger 7986: <p>There are several reasons why a package might be
7987: instructed to not build under certain circumstances. If the
7988: package builds and runs on most platforms, the exceptions
7989: should be noted with <code class="varname">NOT_FOR_PLATFORM</code>. If
7990: the package builds and runs on a small handful of platforms,
7991: set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
7992: Both <code class="varname">ONLY_FOR_PLATFORM</code> and
7993: <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
7994: (OS-version-platform) that can use glob-style
7995: wildcards.</p>
7996: <p>Some packages are tightly bound to a specific version of an
7997: operating system, e.g. LKMs or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/sysutils/lsof/README.html" target="_top"><code class="filename">sysutils/lsof</code></a>. Such binary packages are not
7998: backwards compatible with other versions of the OS, and should be
7999: uploaded to a version specific directory on the FTP server. Mark
8000: these packages by setting <code class="varname">OSVERSION_SPECIFIC</code> to
8001: “<span class="quote">yes</span>”. This variable is not currently used by any of
8002: the package system internals, but may be used in the
8003: future.</p>
8004: <p>If the package should be skipped (for example, because it
8005: provides functionality already provided by the system), set
8006: <code class="varname">PKG_SKIP_REASON</code> to a descriptive message. If
8007: the package should fail because some preconditions are not met,
8008: set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
8009: message.</p>
8010: </div>
8011: <div class="sect2" lang="en">
8012: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8013: <a name="undeletable-packages"></a>19.1.9. Packages which should not be deleted, once installed</h3></div></div></div>
1.1 dsieger 8014: <p>To ensure that a package may not be deleted, once it has been
8015: installed, the <code class="varname">PKG_PRESERVE</code> definition should
8016: be set in the package Makefile. This will be carried into any
8017: binary package that is made from this pkgsrc entry. A
8018: “<span class="quote">preserved</span>” package will
1.10 hubertf 8019: not be deleted using <a class="citerefentry" 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
1.1 dsieger 8020: “<span class="quote">-f</span>” option is used.</p>
8021: </div>
8022: <div class="sect2" lang="en">
8023: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8024: <a name="security-handling"></a>19.1.10. Handling packages with security problems</h3></div></div></div>
1.1 dsieger 8025: <p>When a vulnerability is found, this should be noted in
8026: <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
1.10 hubertf 8027: and after committing that file, use <span class="command"><strong>make upload</strong></span>
1.1 dsieger 8028: in the same directory to update the file on ftp.NetBSD.org.</p>
8029: <p>After fixing the vulnerability by a patch, its
8030: <code class="varname">PKGREVISION</code> should be increased (this
8031: is of course not necessary if the problem is fixed by using
8032: a newer release of the software).</p>
8033: <p>Also, if the fix should be applied to the stable pkgsrc
8034: branch, be sure to submit a pullup request!</p>
8035: <p>Binary packages already on ftp.NetBSD.org will be handled
8036: semi-automatically by a weekly cron job.</p>
8037: </div>
8038: <div class="sect2" lang="en">
8039: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8040: <a name="bumping-pkgrevision"></a>19.1.11. How to handle incrementing versions when fixing an existing package</h3></div></div></div>
1.1 dsieger 8041: <p>When making fixes to an existing package it can be useful
8042: to change the version number in <code class="varname">PKGNAME</code>. To
8043: avoid conflicting with future versions by the original author, a
8044: “<span class="quote">nb1</span>”, “<span class="quote">nb2</span>”, ... suffix can be used
8045: on package versions by setting <code class="varname">PKGREVISION=1</code>
8046: (2, ...). The “<span class="quote">nb</span>” is treated like a
8047: “<span class="quote">.</span>” by the package tools. e.g.</p>
8048: <pre class="programlisting">
8049: DISTNAME= foo-17.42
8050: PKGREVISION= 9
8051: </pre>
8052: <p>will result in a <code class="varname">PKGNAME</code> of
8053: “<span class="quote">foo-17.42nb9</span>”. If you want to use the original
8054: value of <code class="varname">PKGNAME</code> without the “<span class="quote">nbX</span>”
8055: suffix, e.g. for setting <code class="varname">DIST_SUBDIR</code>, use
8056: <code class="varname">PKGNAME_NOREV</code>.</p>
8057: <p>When a new release of the package is released, the
8058: <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
8059: minor release of the above package, things should be like:</p>
8060: <pre class="programlisting">
8061: DISTNAME= foo-17.43
8062: </pre>
8063: <p><code class="varname">PKGREVISION</code> should be incremented for any
8064: non-trivial change in the resulting binary package. Without a
8065: <code class="varname">PKGREVISION</code> bump, someone with the previous
8066: version installed has no way of knowing that their package is out
8067: of date. Thus, changes without increasing
8068: <code class="varname">PKGREVISION</code> are essentially labeled "this is so
8069: trivial that no reasonable person would want to upgrade", and this
8070: is the rough test for when increasing
8071: <code class="varname">PKGREVISION</code> is appropriate. Examples of
8072: changes that do not merit increasing
8073: <code class="varname">PKGREVISION</code> are:</p>
8074: <div class="itemizedlist"><ul type="disc">
1.14 ! jmcneill 8075: <li><p>Changing <code class="varname">HOMEPAGE</code>,
! 8076: <code class="varname">MAINTAINER</code>, <code class="varname">OWNER</code>,
1.1 dsieger 8077: or comments in Makefile.</p></li>
8078: <li><p>
8079: Changing build variables if the resulting binary package is the same.</p></li>
8080: <li><p>
8081: Changing <code class="filename">DESCR</code>.</p></li>
8082: <li><p>
8083: Adding <code class="varname">PKG_OPTIONS</code> if the default options don't change.</p></li>
8084: </ul></div>
8085: <p>Examples of changes that do merit an increase to
8086: <code class="varname">PKGREVISION</code> include:</p>
8087: <div class="itemizedlist"><ul type="disc">
8088: <li><p>
8089: Security fixes</p></li>
8090: <li><p>
8091: Changes or additions to a patch file</p></li>
8092: <li><p>
8093: Changes to the <code class="filename">PLIST</code></p></li>
1.12 weinem 8094: <li><p>A dependency is changed or renamed.</p></li>
1.1 dsieger 8095: </ul></div>
8096: <p>PKGREVISION must also be incremented when dependencies have ABI
8097: changes.</p>
8098: </div>
8099: <div class="sect2" lang="en">
8100: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8101: <a name="fixes.subst"></a>19.1.12. Substituting variable text in the package files (the SUBST framework)</h3></div></div></div>
1.1 dsieger 8102: <p>When you want to replace the same text in multiple files
8103: or when the replacement text varies, patches alone cannot help.
8104: This is where the SUBST framework comes in. It provides an
8105: easy-to-use interface for replacing text in files.
8106: Example:</p>
8107: <pre class="programlisting">
8108: SUBST_CLASSES+= fix-paths
8109: SUBST_STAGE.fix-paths= pre-configure
8110: SUBST_MESSAGE.fix-paths= Fixing absolute paths.
8111: SUBST_FILES.fix-paths= src/*.c
8112: SUBST_FILES.fix-paths+= scripts/*.sh
8113: SUBST_SED.fix-paths= -e 's,"/usr/local,"${PREFIX},g'
8114: SUBST_SED.fix-paths+= -e 's,"/var/log,"${VARBASE}/log,g'
8115: </pre>
8116: <p><code class="varname">SUBST_CLASSES</code> is a list of identifiers
8117: that are used to identify the different SUBST blocks that are
8118: defined. The SUBST framework is heavily used by pkgsrc, so it is
8119: important to always use the <code class="literal">+=</code> operator with
8120: this variable. Otherwise some substitutions may be
8121: skipped.</p>
8122: <p>The remaining variables of each SUBST block are
8123: parameterized with the identifier from the first line
8124: (<code class="literal">fix-paths</code> in this case.) They can be seen as
8125: parameters to a function call.</p>
8126: <p><code class="varname">SUBST_STAGE.*</code> specifies the stage at
8127: which the replacement will take place. All combinations of
8128: <code class="literal">pre-</code>, <code class="literal">do-</code> and
8129: <code class="literal">post-</code> together with a phase name are
8130: possible, though only few are actually used. Most commonly used
8131: are <code class="literal">post-patch</code> and
8132: <code class="literal">pre-configure</code>. Of these two,
8133: <code class="literal">pre-configure</code> should be preferred because
1.10 hubertf 8134: then it is possible to run <span class="command"><strong>bmake patch</strong></span> and
1.1 dsieger 8135: have the state after applying the patches but before making any
8136: other changes. This is especially useful when you are debugging
8137: a package in order to create new patches for it. Similarly,
8138: <code class="literal">post-build</code> is preferred over
8139: <code class="literal">pre-install</code>, because the install phase should
8140: generally be kept as simple as possible. When you use
8141: <code class="literal">post-build</code>, you have the same files in the
8142: working directory that will be installed later, so you can check
8143: if the substitution has succeeded.</p>
8144: <p><code class="varname">SUBST_MESSAGE.*</code> is an optional text
8145: that is printed just before the substitution is done.</p>
8146: <p><code class="varname">SUBST_FILES.*</code> is the list of shell
8147: globbing patterns that specifies the files in which the
8148: substitution will take place. The patterns are interpreted
8149: relatively to the <code class="varname">WRKSRC</code> directory.</p>
8150: <p><code class="varname">SUBST_SED.*</code> is a list of arguments to
1.10 hubertf 8151: <a class="citerefentry" 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
1.1 dsieger 8152: command should be prefixed with <code class="literal">-e</code>, so that
8153: all SUBST blocks look uniform.</p>
8154: <p>There are some more variables, but they are so seldomly
8155: used that they are only documented in the
8156: <code class="filename">mk/subst.mk</code> file.</p>
8157: </div>
8158: </div>
8159: <div class="sect1" lang="en">
8160: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 8161: <a name="fixes.fetch"></a>19.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.1 dsieger 8162: <div class="sect2" lang="en">
8163: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8164: <a name="no-plain-download"></a>19.2.1. Packages whose distfiles aren't available for plain downloading</h3></div></div></div>
1.1 dsieger 8165: <p>If you need to download from a dynamic URL you can set
1.10 hubertf 8166: <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span class="command"><strong>make
1.1 dsieger 8167: fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
8168: with the name of each file to download as an argument, expecting
8169: it to output the URL of the directory from which to download
8170: it. <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/graphics/ns-cult3d/README.html" target="_top"><code class="filename">graphics/ns-cult3d</code></a> is an
8171: example of this usage.</p>
8172: <p>If the download can't be automated, because the user must
8173: submit personal information to apply for a password, or must pay
8174: for the source, or whatever, you can set
8175: <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
8176: displayed to the user before aborting the build. Example:</p>
8177: <pre class="programlisting">
8178: FETCH_MESSAGE= "Please download the files"
8179: FETCH_MESSAGE+= " "${DISTFILES:Q}
8180: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
8181: </pre>
8182: </div>
8183: <div class="sect2" lang="en">
8184: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8185: <a name="modified-distfiles-same-name"></a>19.2.2. How to handle modified distfiles with the 'old' name</h3></div></div></div>
1.1 dsieger 8186: <p>Sometimes authors of a software package make some
8187: modifications after the software was released, and they put up a
8188: new distfile without changing the package's version number. If a
8189: package is already in pkgsrc at that time, the checksum will
8190: no longer match. The contents of the new distfile should be
8191: compared against the old one before changing anything, to make
8192: sure the distfile was really updated on purpose, and that
8193: no trojan horse or so crept in.
8194: Please mention that the distfiles were compared and what was found
8195: in your commit message.
8196: Then, the correct way to work around this is to
8197: set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
8198: usually based on <code class="varname">PKGNAME_NOREV</code>. All
8199: <code class="varname">DISTFILES</code> and
8200: <code class="varname">PATCHFILES</code> for this package will be put in that
8201: subdirectory of the local distfiles directory.
1.10 hubertf 8202: (See <a class="xref" href="#bumping-pkgrevision" title="19.1.11. How to handle incrementing versions when fixing an existing package">Section 19.1.11, “How to handle incrementing versions when fixing an existing package”</a> for more details.)
1.1 dsieger 8203: In case this
8204: happens more often, <code class="varname">PKGNAME</code> can be used (thus
8205: including the <code class="filename">nbX</code> suffix) or a date stamp
8206: can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
8207: Do not forget regenerating the <code class="filename">distinfo</code> file
8208: after that, since it contains the <code class="varname">DIST_SUBDIR</code>
8209: path in the filenames.
8210: Also increase the PKGREVISION if the installed package is different.
8211: Furthermore, a mail to the package's authors seems appropriate
8212: telling them that changing distfiles after releases without
8213: changing the file names is not good practice.</p>
8214: </div>
8215: </div>
8216: <div class="sect1" lang="en">
8217: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 8218: <a name="fixes.configure"></a>19.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.1 dsieger 8219: <div class="sect2" lang="en">
8220: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8221: <a name="fixes.libtool"></a>19.3.1. Shared libraries - libtool</h3></div></div></div>
1.1 dsieger 8222: <p>pkgsrc supports many different machines, with different
8223: object formats like a.out and ELF, and varying abilities to do
8224: shared library and dynamic loading at all. To accompany this,
8225: varying commands and options have to be passed to the
8226: compiler, linker, etc. to get the Right Thing, which can be
8227: pretty annoying especially if you don't have all the machines
8228: at your hand to test things. The
8229: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/libtool/README.html" target="_top"><code class="filename">devel/libtool</code></a> pkg
8230: can help here, as it just “<span class="quote">knows</span>” how to build
8231: both static and dynamic libraries from a set of source files,
8232: thus being platform-independent.</p>
8233: <p>Here's how to use libtool in a package in seven simple
8234: steps:</p>
8235: <div class="orderedlist"><ol type="1">
8236: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
8237: Makefile.</p></li>
8238: <li><p>For library objects, use “<span class="quote">${LIBTOOL} --mode=compile
8239: ${CC}</span>” in place of “<span class="quote">${CC}</span>”. You could even
8240: add it to the definition of <code class="varname">CC</code>, if only
8241: libraries are being built in a given Makefile. This one command
8242: will build both PIC and non-PIC library objects, so you need not
8243: have separate shared and non-shared library rules.</p></li>
8244: <li>
8245: <p>For the linking of the library, remove any
8246: “<span class="quote">ar</span>”, “<span class="quote">ranlib</span>”, and “<span class="quote">ld
8247: -Bshareable</span>” commands, and instead use:</p>
8248: <pre class="programlisting">
8249: ${LIBTOOL} --mode=link \
8250: ${CC} -o ${.TARGET:.a=.la} \
8251: ${OBJS:.o=.lo} \
8252: -rpath ${PREFIX}/lib \
8253: -version-info major:minor
8254: </pre>
8255: <p>Note that the library is changed to have a
8256: <code class="filename">.la</code> extension, and the objects are
8257: changed to have a <code class="filename">.lo</code>
8258: extension. Change <code class="varname">OBJS</code> as
8259: necessary. This automatically creates all of the
8260: <code class="filename">.a</code>,
8261: <code class="filename">.so.major.minor</code>, and ELF symlinks (if
8262: necessary) in the build directory. Be sure to include
8263: “<span class="quote">-version-info</span>”, especially when major and
8264: minor are zero, as libtool will otherwise strip off the
8265: shared library version.</p>
8266: <p>From the libtool manual:</p>
8267: <pre class="programlisting">
8268: So, libtool library versions are described by three integers:
8269:
8270: CURRENT
8271: The most recent interface number that this library implements.
8272:
8273: REVISION
8274: The implementation number of the CURRENT interface.
8275:
8276: AGE
8277: The difference between the newest and oldest interfaces that
8278: this library implements. In other words, the library implements
8279: all the interface numbers in the range from number `CURRENT -
8280: AGE' to `CURRENT'.
8281:
8282: If two libraries have identical CURRENT and AGE numbers, then the
8283: dynamic linker chooses the library with the greater REVISION number.
8284: </pre>
8285: <p>The “<span class="quote">-release</span>” option will produce
8286: different results for a.out and ELF (excluding symlinks)
8287: in only one case. An ELF library of the form
8288: “<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
8289: will have a symlink of
8290: “<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
8291: on an a.out platform. This is handled
8292: automatically.</p>
8293: <p>The “<span class="quote">-rpath argument</span>” is the install
8294: directory of the library being built.</p>
8295: <p>In the <code class="filename">PLIST</code>, include only the
8296: <code class="filename">.la</code> file, the other files will be
8297: added automatically.</p>
8298: </li>
8299: <li>
8300: <p>When linking shared object (<code class="filename">.so</code>)
1.10 hubertf 8301: files, i.e. files that are loaded via <a class="citerefentry" 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
1.1 dsieger 8302: shared libraries, use “<span class="quote">-module
8303: -avoid-version</span>” to prevent them getting version
8304: tacked on.</p>
8305: <p>The <code class="filename">PLIST</code> file gets the
8306: <code class="filename">foo.so</code> entry.</p>
8307: </li>
8308: <li>
8309: <p>When linking programs that depend on these libraries
8310: <span class="emphasis"><em>before</em></span> they are installed, preface
1.10 hubertf 8311: the <a class="citerefentry" 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 class="citerefentry" 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}
1.1 dsieger 8312: --mode=link</span>”, and it will find the correct
8313: libraries (static or shared), but please be aware that
8314: libtool will not allow you to specify a relative path in
8315: -L (such as “<span class="quote">-L../somelib</span>”), because it
8316: expects you to change that argument to be the
8317: <code class="filename">.la</code> file. e.g.</p>
8318: <pre class="programlisting">
8319: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
8320: </pre>
8321: <p>should be changed to:</p>
8322: <pre class="programlisting">
8323: ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
8324: </pre>
8325: <p>and it will do the right thing with the libraries.</p>
8326: </li>
8327: <li>
1.10 hubertf 8328: <p>When installing libraries, preface the <a class="citerefentry" href="http://netbsd.gw.com/cgi-bin/man-cgi?install+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">install</span>(1)</span></a>
8329: or <a class="citerefentry" 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}
1.1 dsieger 8330: --mode=install</span>”, and change the library name to
8331: <code class="filename">.la</code>. e.g.</p>
8332: <pre class="programlisting">
8333: ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
8334: </pre>
8335: <p>This will install the static <code class="filename">.a</code>,
8336: shared library, any needed symlinks, and run
1.10 hubertf 8337: <a class="citerefentry" 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.1 dsieger 8338: </li>
8339: <li><p>In your <code class="filename">PLIST</code>, include only
8340: the <code class="filename">.la</code>
8341: file (this is a change from previous behaviour).</p></li>
8342: </ol></div>
8343: </div>
8344: <div class="sect2" lang="en">
8345: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8346: <a name="using-libtool"></a>19.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
1.1 dsieger 8347: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
8348: package Makefile. This will override the package's own libtool
8349: in most cases. For older libtool using packages, libtool is
8350: made by ltconfig script during the do-configure step; you can
1.10 hubertf 8351: check the libtool script location by doing <span class="command"><strong>make
1.1 dsieger 8352: configure; find work*/ -name libtool</strong></span>.</p>
8353: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
8354: scripts, relative to <code class="varname">WRKSRC</code>, to override. By
8355: default, it is set to “<span class="quote">libtool */libtool
8356: */*/libtool</span>”. If this does not match the location of the
8357: package's libtool script(s), set it as appropriate.</p>
8358: <p>If you do not need <code class="filename">*.a</code> static
8359: libraries built and installed, then use
8360: <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
8361: <p>If your package makes use of the platform-independent library
8362: for loading dynamic shared objects, that comes with libtool
8363: (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
8364: <p>Some packages use libtool incorrectly so that the package
8365: may not work or build in some circumstances. Some of the more
8366: common errors are:</p>
8367: <div class="itemizedlist"><ul type="disc">
8368: <li>
8369: <p>The inclusion of a shared object (-module) as a dependent library in an
8370: executable or library. This in itself isn't a problem if one of two things
8371: has been done:</p>
8372: <div class="orderedlist"><ol type="1">
8373: <li><p>The shared object is named correctly, i.e.
8374: <code class="filename">libfoo.la</code>, not
8375: <code class="filename">foo.la</code></p></li>
8376: <li><p>The -dlopen option is used when linking an executable.</p></li>
8377: </ol></div>
8378: </li>
8379: <li><p>The use of libltdl without the correct calls to initialisation routines.
8380: The function lt_dlinit() should be called and the macro
8381: <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
8382: executables.</p></li>
8383: </ul></div>
8384: </div>
8385: <div class="sect2" lang="en">
8386: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8387: <a name="autoconf-automake"></a>19.3.3. GNU Autoconf/Automake</h3></div></div></div>
1.1 dsieger 8388: <p>If a package needs GNU autoconf or automake to be executed
8389: to regenerate the configure script and Makefile.in makefile
8390: templates, then they should be executed in a pre-configure
8391: target.</p>
8392: <p>For packages that need only autoconf:</p>
8393: <pre class="programlisting">
8394: AUTOCONF_REQD= 2.50 # if default version is not good enough
8395: USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
8396: ...
8397:
8398: pre-configure:
8399: cd ${WRKSRC} && autoconf
8400:
8401: ...
8402: </pre>
8403: <p>and for packages that need automake and autoconf:</p>
8404: <pre class="programlisting">
8405: AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
8406: USE_TOOLS+= automake # use "automake14" for automake-1.4
8407: ...
8408:
8409: pre-configure:
8410: set -e; cd ${WRKSRC}; \
8411: aclocal; autoheader; automake -a --foreign -i; autoconf
8412:
8413: ...
8414: </pre>
8415: <p>Packages which use GNU Automake will almost certainly
8416: require GNU Make.</p>
8417: <p>There are times when the configure process makes
8418: additional changes to the generated files, which then causes
8419: the build process to try to re-execute the automake sequence.
8420: This is prevented by touching various files in the configure
8421: stage. If this causes problems with your package you can set
8422: <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
8423: Makefile.</p>
8424: </div>
8425: </div>
8426: <div class="sect1" lang="en">
8427: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 8428: <a name="programming-languages"></a>19.4. Programming languages</h2></div></div></div>
1.1 dsieger 8429: <div class="sect2" lang="en">
8430: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8431: <a name="basic-programming-languages"></a>19.4.1. C, C++, and Fortran</h3></div></div></div>
1.1 dsieger 8432: <p>Compilers for the C, C++, and Fortran languages comes with
8433: the NetBSD base system. By default, pkgsrc assumes that a package
8434: is written in C and will hide all other compilers (via the wrapper
1.10 hubertf 8435: framework, see <a class="xref" href="#buildlink" title="Chapter 14. Buildlink methodology">Chapter 14, <i>Buildlink methodology</i></a>).</p>
1.1 dsieger 8436: <p>To declare which language's compiler a package needs, set
8437: the <code class="varname">USE_LANGUAGES</code> variable. Allowed values
8438: currently are “<span class="quote">c</span>”, “<span class="quote">c++</span>”, and
8439: “<span class="quote">fortran</span>” (and any combination). The default is
8440: “<span class="quote">c</span>”. Packages using GNU configure scripts, even if
8441: written in C++, usually need a C compiler for the configure
8442: phase.</p>
8443: </div>
8444: <div class="sect2" lang="en">
8445: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8446: <a name="java-programming-language"></a>19.4.2. Java</h3></div></div></div>
1.1 dsieger 8447: <p>If a program is written in Java, use the Java framework in
8448: pkgsrc. The package must include
8449: <code class="filename">../../mk/java-vm.mk</code>. This Makefile fragment
8450: provides the following variables:</p>
8451: <div class="itemizedlist"><ul type="disc">
8452: <li><p><code class="varname">USE_JAVA</code> defines if a build
8453: dependency on the JDK is added. If
8454: <code class="varname">USE_JAVA</code> is set to “<span class="quote">run</span>”, then
8455: there is only a runtime dependency on the JDK. The default is
8456: “<span class="quote">yes</span>”, which also adds a build dependency on the
8457: JDK.</p></li>
8458: <li><p>Set <code class="varname">USE_JAVA2</code> to declare that
8459: a package needs a Java2 implementation. The supported values
8460: are “<span class="quote">yes</span>”, “<span class="quote">1.4</span>”, and
8461: “<span class="quote">1.5</span>”. “<span class="quote">yes</span>” accepts any Java2
8462: implementation, “<span class="quote">1.4</span>” insists on versions 1.4 or
8463: above, and “<span class="quote">1.5</span>” only accepts versions 1.5 or
8464: above. This variable is not set by default.</p></li>
8465: </ul></div>
8466: </div>
8467: <div class="sect2" lang="en">
8468: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8469: <a name="perl-scripts"></a>19.4.3. Packages containing perl scripts</h3></div></div></div>
1.1 dsieger 8470: <p>If your package contains interpreted perl scripts, add
8471: “<span class="quote">perl</span>” to the <code class="varname">USE_TOOLS</code> variable
8472: and set <code class="varname">REPLACE_PERL</code> to ensure that the proper
8473: interpreter path is set. <code class="varname">REPLACE_PERL</code> should
8474: contain a list of scripts, relative to <code class="varname">WRKSRC</code>,
8475: that you want adjusted. Every occurrence of
8476: <code class="filename">*/bin/perl</code> will be replaced with the full
8477: path to the perl executable.</p>
8478: <p>If a particular version of perl is needed, set the
8479: <code class="varname">PERL5_REQD</code> variable to the version number. The
8480: default is “<span class="quote">5.0</span>”.</p>
1.10 hubertf 8481: <p>See <a class="xref" href="#perl-modules" title="19.6.6. Packages installing perl modules">Section 19.6.6, “Packages installing perl modules”</a> for information
1.1 dsieger 8482: about handling perl modules.</p>
8483: </div>
8484: <div class="sect2" lang="en">
8485: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8486: <a name="other-programming-languages"></a>19.4.4. Other programming languages</h3></div></div></div>
1.1 dsieger 8487: <p>Currently, there is no special handling for other languages
8488: in pkgsrc. If a compiler package provides a
8489: <code class="filename">buildlink3.mk</code> file, include that, otherwise
8490: just add a (build) dependency on the appropriate compiler
8491: package.</p>
8492: </div>
8493: </div>
8494: <div class="sect1" lang="en">
8495: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 8496: <a name="fixes.build"></a>19.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.1 dsieger 8497: <p>The most common failures when building a package are that
8498: some platforms do not provide certain header files, functions or
8499: libraries, or they provide the functions in a library that the
8500: original package author didn't know. To work around this, you
8501: can rewrite the source code in most cases so that it does not
8502: use the missing functions or provides a replacement function.</p>
8503: <div class="sect2" lang="en">
8504: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8505: <a name="fixes.build.cpp"></a>19.5.1. Compiling C and C++ code conditionally</h3></div></div></div>
1.1 dsieger 8506: <p>If a package already comes with a GNU configure script, the
8507: preferred way to fix the build failure is to change the
8508: configure script, not the code. In the other cases, you can
8509: utilize the C preprocessor, which defines certain macros
8510: depending on the operating system and hardware architecture it
8511: compiles for. These macros can be queried using for example
8512: <code class="varname">#if defined(__i386)</code>. Almost every operating
8513: system, hardware architecture and compiler has its own macro.
8514: For example, if the macros <code class="varname">__GNUC__</code>,
8515: <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
8516: are all defined, you know that you are using NetBSD on an i386
8517: compatible CPU, and your compiler is GCC.</p>
8518: <p>The list of the following macros for hardware and
8519: operating system depends on the compiler that is used. For
8520: example, if you want to conditionally compile code on Solaris,
8521: don't use <code class="varname">__sun__</code>, as the SunPro compiler
8522: does not define it. Use <code class="varname">__sun</code> instead.</p>
8523: <div class="sect3" lang="en">
8524: <div class="titlepage"><div><div><h4 class="title">
1.6 rillig 8525: <a name="fixes.build.cpp.os"></a>19.5.1.1. C preprocessor macros to identify the operating system</h4></div></div></div>
1.1 dsieger 8526: <p>To distinguish between 4.4 BSD-derived systems and the
8527: rest of the world, you should use the following code.</p>
8528: <pre class="programlisting">
8529: #include <sys/param.h>
8530: #if (defined(BSD) && BSD >= 199306)
8531: /* BSD-specific code goes here */
8532: #else
8533: /* non-BSD-specific code goes here */
8534: #endif
8535: </pre>
8536: <p>If this distinction is not fine enough, you can also test
8537: for the following macros.</p>
8538: <pre class="programlisting">
8539: FreeBSD __FreeBSD__
8540: DragonFly __DragonFly__
8541: Interix __INTERIX
8542: IRIX __sgi (TODO: get a definite source for this)
8543: Linux linux, __linux, __linux__
8544: NetBSD __NetBSD__
8545: OpenBSD __OpenBSD__
8546: Solaris sun, __sun
8547: </pre>
8548: </div>
8549: <div class="sect3" lang="en">
8550: <div class="titlepage"><div><div><h4 class="title">
1.6 rillig 8551: <a name="fixes.build.cpp.arch"></a>19.5.1.2. C preprocessor macros to identify the hardware architecture</h4></div></div></div>
1.1 dsieger 8552: <pre class="programlisting">
8553: i386 i386, __i386, __i386__
8554: MIPS __mips
8555: SPARC sparc, __sparc
8556: </pre>
8557: </div>
8558: <div class="sect3" lang="en">
8559: <div class="titlepage"><div><div><h4 class="title">
1.6 rillig 8560: <a name="fixes.build.cpp.compiler"></a>19.5.1.3. C preprocessor macros to identify the compiler</h4></div></div></div>
1.1 dsieger 8561: <pre class="programlisting">
8562: GCC __GNUC__ (major version), __GNUC_MINOR__
8563: MIPSpro _COMPILER_VERSION (0x741 for MIPSpro 7.41)
8564: SunPro __SUNPRO_C (0x570 for Sun C 5.7)
8565: SunPro C++ __SUNPRO_CC (0x580 for Sun C++ 5.8)
8566: </pre>
8567: </div>
8568: </div>
8569: <div class="sect2" lang="en">
8570: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8571: <a name="compiler-bugs"></a>19.5.2. How to handle compiler bugs</h3></div></div></div>
1.1 dsieger 8572: <p>Some source files trigger bugs in the compiler, based on
8573: combinations of compiler version and architecture and almost
8574: always relation to optimisation being enabled. Common symptoms
8575: are gcc internal errors or never finishing compiling a
8576: file.</p>
8577: <p>Typically, a workaround involves testing the
8578: <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
8579: optimisation for that combination of file,
8580: <code class="varname">MACHINE_ARCH</code> and compiler, and documenting it
8581: in <code class="filename">pkgsrc/doc/HACKS</code>. See that file for a
8582: number of examples.</p>
8583: </div>
8584: <div class="sect2" lang="en">
8585: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8586: <a name="undefined-reference"></a>19.5.3. Undefined reference to “<span class="quote">...</span>”</h3></div></div></div>
1.1 dsieger 8587: <p>This error message often means that a package did not
8588: link to a shared library it needs. The following functions are
8589: known to cause this error message over and over.</p>
8590: <div class="informaltable">
8591: <a name="undefined-reference-functions"></a><table border="1">
8592: <colgroup>
8593: <col>
8594: <col>
8595: <col>
8596: </colgroup>
8597: <thead><tr>
8598: <th>Function</th>
8599: <th>Library</th>
8600: <th>Affected platforms</th>
8601: </tr></thead>
8602: <tbody>
8603: <tr>
8604: <td>accept, bind, connect</td>
8605: <td>-lsocket</td>
8606: <td>Solaris</td>
8607: </tr>
8608: <tr>
8609: <td>crypt</td>
8610: <td>-lcrypt</td>
8611: <td>DragonFly, NetBSD</td>
8612: </tr>
8613: <tr>
8614: <td>dlopen, dlsym</td>
8615: <td>-ldl</td>
8616: <td>Linux</td>
8617: </tr>
8618: <tr>
8619: <td>gethost*</td>
8620: <td>-lnsl</td>
8621: <td>Solaris</td>
8622: </tr>
8623: <tr>
8624: <td>inet_aton</td>
8625: <td>-lresolv</td>
8626: <td>Solaris</td>
8627: </tr>
8628: <tr>
8629: <td>nanosleep, sem_*, timer_*</td>
8630: <td>-lrt</td>
8631: <td>Solaris</td>
8632: </tr>
8633: <tr>
8634: <td>openpty</td>
8635: <td>-lutil</td>
8636: <td>Linux</td>
8637: </tr>
8638: </tbody>
8639: </table>
8640: </div>
8641: <p>To fix these linker errors, it is often sufficient to say
8642: <code class="literal">LIBS.<em class="replaceable"><code>OperatingSystem</code></em>+=
8643: -l<em class="replaceable"><code>foo</code></em></code> to the package
1.10 hubertf 8644: <code class="filename">Makefile</code> and then say <span class="command"><strong>bmake clean;
1.1 dsieger 8645: bmake</strong></span>.</p>
8646: <div class="sect3" lang="en">
8647: <div class="titlepage"><div><div><h4 class="title">
1.6 rillig 8648: <a name="undefined-reference-sunpro"></a>19.5.3.1. Special issue: The SunPro compiler</h4></div></div></div>
1.1 dsieger 8649: <p>When you are using the SunPro compiler, there is another
8650: possibility. That compiler cannot handle the following code:</p>
8651: <pre class="programlisting">
8652: extern int extern_func(int);
8653:
8654: static inline int
8655: inline_func(int x)
8656: {
8657: return extern_func(x);
8658: }
8659:
8660: int main(void)
8661: {
8662: return 0;
8663: }
8664: </pre>
8665: <p>It generates the code for <code class="function">inline_func</code> even if
8666: that function is never used. This code then refers to
8667: <code class="function">extern_func</code>, which can usually not be resolved. To
8668: solve this problem you can try to tell the package to disable inlining
8669: of functions.</p>
8670: </div>
8671: </div>
8672: <div class="sect2" lang="en">
8673: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8674: <a name="out-of-memory"></a>19.5.4. Running out of memory</h3></div></div></div>
1.1 dsieger 8675: <p>Sometimes packages fail to build because the compiler runs
8676: into an operating system specific soft limit. With the
8677: <code class="varname">UNLIMIT_RESOURCES</code> variable pkgsrc can be told
8678: to unlimit the resources. Currently, the allowed values are
8679: “<span class="quote">datasize</span>” and “<span class="quote">stacksize</span>” (or both).
8680: Setting this variable is similar to running the shell builtin
1.10 hubertf 8681: <span class="command"><strong>ulimit</strong></span> command to raise the maximum data
1.1 dsieger 8682: segment size or maximum stack size of a process, respectively, to
8683: their hard limits.</p>
8684: </div>
8685: </div>
8686: <div class="sect1" lang="en">
8687: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 8688: <a name="fixes.install"></a>19.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.1 dsieger 8689: <div class="sect2" lang="en">
8690: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8691: <a name="install-scripts"></a>19.6.1. Creating needed directories</h3></div></div></div>
1.10 hubertf 8692: <p>The BSD-compatible <span class="command"><strong>install</strong></span> supplied
1.1 dsieger 8693: with some operating systems cannot create more than one
8694: directory at a time. As such, you should call
8695: <code class="literal">${INSTALL_*_DIR}</code> like this:</p>
8696: <pre class="programlisting">
8697: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
8698: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
8699: </pre>
8700: <p>You can also just append “<span class="quote"><code class="literal">dir1
8701: dir2</code></span>” to the
8702: <code class="varname">INSTALLATION_DIRS</code> variable, which will
8703: automatically do the right thing.</p>
8704: </div>
8705: <div class="sect2" lang="en">
8706: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8707: <a name="where-to-install-documentation"></a>19.6.2. Where to install documentation</h3></div></div></div>
1.1 dsieger 8708: <p>In general, documentation should be installed into
8709: <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
8710: <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the latter
8711: includes the version number of the package).</p>
8712: <p>Many modern packages using GNU autoconf allow to set the
8713: directory where HTML documentation is installed with the
8714: “<span class="quote">--with-html-dir</span>” option. Sometimes using this flag
8715: is needed because otherwise the documentation ends up in
8716: <code class="filename">${PREFIX}/share/doc/html</code> or other
8717: places.</p>
8718: <p>An exception to the above is that library API documentation
8719: generated with the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/textproc/gtk-doc/README.html" target="_top"><code class="filename">textproc/gtk-doc</code></a> tools, for use by special
8720: browsers (devhelp) should be left at their default location, which
8721: is <code class="filename">${PREFIX}/share/gtk-doc</code>. Such
8722: documentation can be recognized from files ending in
8723: <code class="filename">.devhelp</code> or <code class="filename">.devhelp2</code>.
8724: (It is also acceptable to install such files in
8725: <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
8726: <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code>; the
8727: <code class="filename">.devhelp*</code> file must be directly in that
8728: directory then, no additional subdirectory level is allowed in
8729: this case. This is usually achieved by using
8730: “<span class="quote">--with-html-dir=${PREFIX}/share/doc</span>”.
8731: <code class="filename">${PREFIX}/share/gtk-doc</code> is preferred
8732: though.)</p>
8733: </div>
8734: <div class="sect2" lang="en">
8735: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8736: <a name="installing-score-files"></a>19.6.3. Installing highscore files</h3></div></div></div>
1.1 dsieger 8737: <p>Certain packages, most of them in the games category, install
8738: a score file that allows all users on the system to record their
8739: highscores. In order for this to work, the binaries need to be
8740: installed setgid and the score files owned by the appropriate
8741: group and/or owner (traditionally the "games" user/group). The
8742: following variables, documented in more detail in
8743: <code class="filename">mk/defaults/mk.conf</code>, control this
8744: behaviour: <code class="varname">SETGIDGAME</code>,
8745: <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
8746: <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
8747: <p>Note that per default, setgid installation of games is
8748: disabled; setting <code class="varname">SETGIDGAME=YES</code> will set all
8749: the other variables accordingly.</p>
1.14 ! jmcneill 8750: <p>A package should therefore never hard code file ownership or
1.1 dsieger 8751: access permissions but rely on <code class="varname">INSTALL_GAME</code> and
8752: <code class="varname">INSTALL_GAME_DATA</code> to set these
8753: correctly.</p>
8754: </div>
8755: <div class="sect2" lang="en">
8756: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8757: <a name="destdir-support"></a>19.6.4. Adding DESTDIR support to packages</h3></div></div></div>
1.14 ! jmcneill 8758: <p><code class="varname">DESTDIR</code> support means that a package
! 8759: installs into a staging directory, not the final location of the
! 8760: files. Then a binary package is created which can be used for
! 8761: installation as usual. There are two ways: Either the package must
! 8762: install as root (“<span class="quote">destdir</span>”) or the package can
! 8763: install as non-root user (“<span class="quote">user-destdir</span>”).</p>
! 8764: <div class="itemizedlist"><ul type="disc">
! 8765: <li><p><code class="varname">PKG_DESTDIR_SUPPORT</code> has to be
! 8766: set to “<span class="quote">destdir</span>” or “<span class="quote">user-destdir</span>”. If
! 8767: bsd.prefs.mk is included in the Makefile,
! 8768: <code class="varname">PKG_DESTDIR_SUPPORT</code> needs to be set before
! 8769: the inclusion.</p></li>
1.4 rillig 8770: <li><p>All installation operations have to be prefixed with
8771: <code class="filename">${DESTDIR}</code>.</p></li>
8772: <li><p>automake gets this DESTDIR mostly right
8773: automatically. Many manual rules and pre/post-install often are
8774: incorrect; fix them.</p></li>
8775: <li><p>If files are installed with special owner/group
8776: either use @owner/@group in the <code class="filename">PLIST</code>
8777: (preferred) or use <code class="varname">SPECIAL_PERMS</code>
8778: (discouraged). Note that @owner/@group are sticky during
8779: install, keep this in mind.</p></li>
8780: <li><p>In general, packages should support
8781: <code class="varname">UNPRIVILEGED</code> to be able to use
8782: DESTDIR.</p></li>
8783: </ul></div>
8784: </div>
8785: <div class="sect2" lang="en">
8786: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8787: <a name="hardcoded-paths"></a>19.6.5. Packages with hardcoded paths to other interpreters</h3></div></div></div>
1.1 dsieger 8788: <p>Your package may also contain scripts with hardcoded paths to
8789: other interpreters besides (or as well as) perl. To correct the
8790: full pathname to the script interpreter, you need to set the
8791: following definitions in your <code class="filename">Makefile</code> (we
1.10 hubertf 8792: shall use <span class="command"><strong>tclsh</strong></span> in this example):</p>
1.1 dsieger 8793: <pre class="programlisting">
8794: REPLACE_INTERPRETER+= tcl
8795: REPLACE.tcl.old= .*/bin/tclsh
8796: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
8797: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
8798: # relative to ${WRKSRC}, just as in REPLACE_PERL
8799: </pre>
8800: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
8801: <h3 class="title">Note</h3>
8802: <p>Before March 2006, these variables were called
8803: <code class="varname">_REPLACE.*</code> and
8804: <code class="varname">_REPLACE_FILES.*</code>.</p>
8805: </div>
8806: </div>
8807: <div class="sect2" lang="en">
8808: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8809: <a name="perl-modules"></a>19.6.6. Packages installing perl modules</h3></div></div></div>
1.1 dsieger 8810: <p>Makefiles of packages providing perl5 modules should include
8811: the Makefile fragment
8812: <code class="filename">../../lang/perl5/module.mk</code>. It provides a
1.10 hubertf 8813: <span class="command"><strong>do-configure</strong></span> target for the standard perl
1.1 dsieger 8814: configuration for such modules as well as various hooks to tune
8815: this configuration. See comments in this file for
8816: details.</p>
8817: <p>Perl5 modules will install into different places depending
8818: on the version of perl used during the build process. To
8819: address this, pkgsrc will append lines to the
8820: <code class="filename">PLIST</code> corresponding to the files listed in
8821: the installed <code class="filename">.packlist</code> file generated by
8822: most perl5 modules. This is invoked by defining
8823: <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
8824: paths to packlist files, e.g.:</p>
8825: <pre class="programlisting">
8826: PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
8827: </pre>
8828: <p>The variables <code class="varname">PERL5_SITELIB</code>,
8829: <code class="varname">PERL5_SITEARCH</code>, and
8830: <code class="varname">PERL5_ARCHLIB</code> represent the three locations
8831: in which perl5 modules may be installed, and may be used by
8832: perl5 packages that don't have a packlist. These three
8833: variables are also substituted for in the
8834: <code class="filename">PLIST</code>.</p>
8835: </div>
8836: <div class="sect2" lang="en">
8837: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8838: <a name="faq.info-files"></a>19.6.7. Packages installing info files</h3></div></div></div>
1.1 dsieger 8839: <p>Some packages install info files or use the
8840: “<span class="quote">makeinfo</span>” or “<span class="quote">install-info</span>”
8841: commands. <code class="varname">INFO_FILES</code> should be defined in
8842: the package Makefile so that <code class="filename">INSTALL</code> and
8843: <code class="filename">DEINSTALL</code> scripts will be generated to
8844: handle registration of the info files in the Info directory
8845: file. The “<span class="quote">install-info</span>” command used for the info
8846: files registration is either provided by the system, or by a
8847: special purpose package automatically added as dependency if
8848: needed.</p>
8849: <p><code class="varname">PKGINFODIR</code> is the directory under
8850: <code class="filename">${PREFIX}</code> where info files are primarily
8851: located. <code class="varname">PKGINFODIR</code> defaults to
8852: “<span class="quote">info</span>” and can be overridden by the user.</p>
8853: <p>The info files for the package should be listed in the
8854: package <code class="filename">PLIST</code>; however any split info files
8855: need not be listed.</p>
8856: <p>A package which needs the “<span class="quote">makeinfo</span>” command
8857: at build time must add “<span class="quote">makeinfo</span>” to
8858: <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
8859: version of the “<span class="quote">makeinfo</span>” command is needed it
8860: should be noted with the <code class="varname">TEXINFO_REQD</code>
8861: variable in the package <code class="filename">Makefile</code>. By
8862: default, a minimum version of 3.12 is required. If the system
1.10 hubertf 8863: does not provide a <span class="command"><strong>makeinfo</strong></span> command or if it
1.1 dsieger 8864: does not match the required minimum, a build dependency on the
8865: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/devel/gtexinfo/README.html" target="_top"><code class="filename">devel/gtexinfo</code></a> package will
8866: be added automatically.</p>
8867: <p>The build and installation process of the software provided
8868: by the package should not use the
1.10 hubertf 8869: <span class="command"><strong>install-info</strong></span> command as the registration of
1.1 dsieger 8870: info files is the task of the package
8871: <code class="filename">INSTALL</code> script, and it must use the
1.10 hubertf 8872: appropriate <span class="command"><strong>makeinfo</strong></span> command.</p>
1.1 dsieger 8873: <p>To achieve this goal, the pkgsrc infrastructure creates
1.10 hubertf 8874: overriding scripts for the <span class="command"><strong>install-info</strong></span> and
8875: <span class="command"><strong>makeinfo</strong></span> commands in a directory listed early
1.1 dsieger 8876: in <code class="varname">PATH</code>.</p>
1.10 hubertf 8877: <p>The script overriding <span class="command"><strong>install-info</strong></span> has
1.1 dsieger 8878: no effect except the logging of a message. The script overriding
1.10 hubertf 8879: <span class="command"><strong>makeinfo</strong></span> logs a message and according to the
1.1 dsieger 8880: value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
1.10 hubertf 8881: <span class="command"><strong>makeinfo</strong></span> command or exit on error.</p>
1.1 dsieger 8882: </div>
8883: <div class="sect2" lang="en">
8884: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8885: <a name="manpages"></a>19.6.8. Packages installing man pages</h3></div></div></div>
1.1 dsieger 8886: <p>All packages that install manual pages should install them
8887: into the same directory, so that there is one common place to look
8888: for them. In pkgsrc, this place is
8889: <code class="literal">${PREFIX}/${PKGMANDIR}</code>, and this expression
8890: should be used in packages. The default for
8891: <code class="varname">PKGMANDIR</code> is
8892: “<span class="quote"><code class="filename">man</code></span>”. Another often-used value
8893: is “<span class="quote"><code class="filename">share/man</code></span>”.</p>
8894: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
8895: <h3 class="title">Note</h3>
8896: <p>The support for a custom <code class="varname">PKGMANDIR</code>
8897: is far from complete.</p>
8898: </div>
8899: <p>The <code class="filename">PLIST</code> files can just use
8900: <code class="filename">man/</code> as the top level directory for the man
8901: page file entries, and the pkgsrc framework will convert as
8902: needed. In all other places, the correct
8903: <code class="varname">PKGMANDIR</code> must be used.</p>
8904: <p>Packages that are
8905: configured with <code class="varname">GNU_CONFIGURE</code> set as
8906: “<span class="quote">yes</span>”, by default will use the
8907: <code class="filename">./configure</code>
8908: --mandir switch to set where the man pages should be installed.
8909: The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
8910: to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.</p>
8911: <p>Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
8912: use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
8913: to “<span class="quote">no</span>”.
8914: Or if the <code class="filename">./configure</code> script uses
8915: a non-standard use of --mandir, you can set
8916: <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.</p>
1.10 hubertf 8917: <p>See <a class="xref" href="#manpage-compression" title="13.5. Man page compression">Section 13.5, “Man page compression”</a> for
1.1 dsieger 8918: information on installation of compressed manual pages.</p>
8919: </div>
8920: <div class="sect2" lang="en">
8921: <div class="titlepage"><div><div><h3 class="title">
1.7 rillig 8922: <a name="gconf-data-files"></a>19.6.9. Packages installing GConf data files</h3></div></div></div>
1.1 dsieger 8923: <p>If a package installs <code class="filename">.schemas</code> or
1.7 rillig 8924: <code class="filename">.entries</code> files, used by GConf,
1.1 dsieger 8925: you need to take some extra steps to make sure they get registered
8926: in the database:</p>
8927: <div class="orderedlist"><ol type="1">
1.7 rillig 8928: <li><p>Include <code class="filename">../../devel/GConf/schemas.mk</code>
1.1 dsieger 8929: instead of its <code class="filename">buildlink3.mk</code> file. This
1.7 rillig 8930: takes care of rebuilding the GConf database at installation and
1.1 dsieger 8931: deinstallation time, and tells the package where to install
1.7 rillig 8932: GConf data files using some standard configure arguments. It
1.1 dsieger 8933: also disallows any access to the database directly from the
8934: package.</p></li>
8935: <li><p>Ensure that the package installs its
8936: <code class="filename">.schemas</code> files under
8937: <code class="filename">${PREFIX}/share/gconf/schemas</code>. If they get
8938: installed under <code class="filename">${PREFIX}/etc</code>, you will
8939: need to manually patch the package.</p></li>
8940: <li><p>Check the PLIST and remove any entries under the etc/gconf
8941: directory, as they will be handled automatically. See
1.10 hubertf 8942: <a class="xref" href="#faq.conf" title="9.13. How do I change the location of configuration files?">Section 9.13, “How do I change the location of configuration files?”</a> for more information.</p></li>
1.7 rillig 8943: <li><p>Define the <code class="varname">GCONF_SCHEMAS</code> variable in
1.1 dsieger 8944: your <code class="filename">Makefile</code> with a list of all
8945: <code class="filename">.schemas</code> files installed by the package, if
8946: any. Names must not contain any directories in them.</p></li>
1.7 rillig 8947: <li><p>Define the <code class="varname">GCONF_ENTRIES</code> variable in
1.1 dsieger 8948: your <code class="filename">Makefile</code> with a
8949: list of all <code class="filename">.entries</code> files installed by the
8950: package, if any. Names must not contain any directories in
8951: them.</p></li>
8952: </ol></div>
8953: </div>
8954: <div class="sect2" lang="en">
8955: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8956: <a name="scrollkeeper-data-files"></a>19.6.10. Packages installing scrollkeeper data files</h3></div></div></div>
1.1 dsieger 8957: <p>If a package installs <code class="filename">.omf</code> files, used by
8958: scrollkeeper, you need to take some extra steps to make sure they
8959: get registered in the database:</p>
8960: <div class="orderedlist"><ol type="1">
8961: <li><p>Include
8962: <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
8963: instead of its <code class="filename">buildlink3.mk</code> file. This
8964: takes care of rebuilding the scrollkeeper database at
8965: installation and deinstallation time, and disallows any access
8966: to it directly from the package.</p></li>
8967: <li><p>Check the PLIST and remove any entries under the
8968: <code class="filename">libdata/scrollkeeper</code> directory, as they
8969: will be handled automatically.</p></li>
8970: <li><p>Remove the <code class="filename">share/omf</code> directory from
8971: the PLIST. It will be handled by scrollkeeper.</p></li>
8972: </ol></div>
8973: </div>
8974: <div class="sect2" lang="en">
8975: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8976: <a name="x11-fonts"></a>19.6.11. Packages installing X11 fonts</h3></div></div></div>
1.1 dsieger 8977: <p>If a package installs font files, you will need to rebuild
8978: the fonts database in the directory where they get installed at
8979: installation and deinstallation time. This can be automatically
8980: done by using the pkginstall framework.</p>
8981: <p>You can list the directories where fonts are installed in the
8982: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
8983: variables, where <em class="replaceable"><code>type</code></em> can be one of
8984: “<span class="quote">ttf</span>”, “<span class="quote">type1</span>” or “<span class="quote">x11</span>”.
8985: Also make sure that the database file
8986: <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
8987: <p>Note that you should not create new directories for fonts;
8988: instead use the standard ones to avoid that the user needs to
8989: manually configure his X server to find them.</p>
8990: </div>
8991: <div class="sect2" lang="en">
8992: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 8993: <a name="gtk2-modules"></a>19.6.12. Packages installing GTK2 modules</h3></div></div></div>
1.1 dsieger 8994: <p>If a package installs GTK2 immodules or loaders, you need to
8995: take some extra steps to get them registered in the GTK2 database
8996: properly:</p>
8997: <div class="orderedlist"><ol type="1">
8998: <li><p>Include
8999: <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
9000: <code class="filename">buildlink3.mk</code> file. This takes care of
9001: rebuilding the database at installation and deinstallation time.</p></li>
9002: <li><p>Set <code class="varname">GTK2_IMMODULES=YES</code> if
9003: your package installs GTK2 immodules.</p></li>
9004: <li><p>Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
9005: GTK2 loaders.</p></li>
9006: <li>
9007: <p>Patch the package to not touch any of the GTK2
9008: databases directly. These are:</p>
9009: <div class="itemizedlist"><ul type="disc">
9010: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
9011: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
9012: </ul></div>
9013: </li>
9014: <li><p>Check the <code class="filename">PLIST</code> and remove
9015: any entries under the <code class="filename">libdata/gtk-2.0</code>
9016: directory, as they will be handled automatically.</p></li>
9017: </ol></div>
9018: </div>
9019: <div class="sect2" lang="en">
9020: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 9021: <a name="sgml-xml-data"></a>19.6.13. Packages installing SGML or XML data</h3></div></div></div>
1.1 dsieger 9022: <p>If a package installs SGML or XML data files that need to be
9023: registered in system-wide catalogs (like DTDs, sub-catalogs,
9024: etc.), you need to take some extra steps:</p>
9025: <div class="orderedlist"><ol type="1">
9026: <li><p>Include
9027: <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
9028: your <code class="filename">Makefile</code>, which takes care of
9029: registering those files in system-wide catalogs at
9030: installation and deinstallation time.</p></li>
9031: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
9032: any SGML catalogs installed by the package.</p></li>
9033: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
9034: any XML catalogs installed by the package.</p></li>
9035: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
9036: to be added to the SGML catalog. These come in groups of
9037: three strings; see xmlcatmgr(1) for more information
9038: (specifically, arguments recognized by the 'add' action).
9039: Note that you will normally not use this variable.</p></li>
9040: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
9041: to be added to the XML catalog. These come in groups of three
9042: strings; see xmlcatmgr(1) for more information (specifically,
9043: arguments recognized by the 'add' action). Note that you will
9044: normally not use this variable.</p></li>
9045: </ol></div>
9046: </div>
9047: <div class="sect2" lang="en">
9048: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 9049: <a name="mime-database"></a>19.6.14. Packages installing extensions to the MIME database</h3></div></div></div>
1.1 dsieger 9050: <p>If a package provides extensions to the MIME database by
9051: installing <code class="filename">.xml</code> files inside
9052: <code class="filename">${PREFIX}/share/mime/packages</code>, you
9053: need to take some extra steps to ensure that the database is kept
9054: consistent with respect to these new files:</p>
9055: <div class="orderedlist"><ol type="1">
9056: <li><p>Include
9057: <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
9058: (avoid using the <code class="filename">buildlink3.mk</code> file from
9059: this same directory, which is reserved for inclusion from
9060: other <code class="filename">buildlink3.mk</code> files). It takes
9061: care of rebuilding the MIME database at installation and
9062: deinstallation time, and disallows any access to it directly
9063: from the package.</p></li>
9064: <li><p>Check the PLIST and remove any entries under the
9065: <code class="filename">share/mime</code> directory,
9066: <span class="emphasis"><em>except</em></span> for files saved under
9067: <code class="filename">share/mime/packages</code>. The former are
9068: handled automatically by
9069: the update-mime-database program, but the latter are
9070: package-dependent and must be removed by the package that
9071: installed them in the first place.</p></li>
9072: <li><p>Remove any <code class="filename">share/mime/*</code> directories
9073: from the PLIST. They will be handled by the shared-mime-info
9074: package.</p></li>
9075: </ol></div>
9076: </div>
9077: <div class="sect2" lang="en">
9078: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 9079: <a name="intltool"></a>19.6.15. Packages using intltool</h3></div></div></div>
1.1 dsieger 9080: <p>If a package uses intltool during its build, add
9081: <code class="literal">intltool</code> to the <code class="varname">USE_TOOLS</code>,
9082: which forces it to use the intltool package provided by pkgsrc,
9083: instead of the one bundled with the distribution file.</p>
9084: <p>This tracks intltool's build-time dependencies and uses the
9085: latest available version; this way, the package benefits of any
9086: bug fixes that may have appeared since it was released.</p>
9087: </div>
9088: <div class="sect2" lang="en">
9089: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 9090: <a name="startup-scripts"></a>19.6.16. Packages installing startup scripts</h3></div></div></div>
1.1 dsieger 9091: <p>If a package contains a rc.d script, it won't be copied into
9092: the startup directory by default, but you can enable it, by adding
9093: the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
1.10 hubertf 9094: <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>. This option will copy the scripts
1.1 dsieger 9095: into <code class="filename">/etc/rc.d</code> when a package is installed, and
9096: it will automatically remove the scripts when the package is
9097: deinstalled.</p>
9098: </div>
9099: <div class="sect2" lang="en">
9100: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 9101: <a name="tex-packages"></a>19.6.17. Packages installing TeX modules</h3></div></div></div>
1.1 dsieger 9102: <p>If a package installs TeX packages into the texmf tree,
9103: the <code class="filename">ls-R</code> database of the tree needs to be
9104: updated.</p>
9105: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
9106: <h3 class="title">Note</h3>
9107: <p>Except the main TeX packages such as teTeX-texmf,
9108: packages should install files
9109: into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
9110: not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
9111: </div>
9112: <div class="orderedlist"><ol type="1">
9113: <li><p>Include
9114: <code class="filename">../../print/teTeX/module.mk</code> instead
9115: of <code class="filename">../../mk/tex.buildlink3.mk</code>. This
9116: takes care of rebuilding the <code class="filename">ls-R</code>
9117: database at installation and deinstallation time.</p></li>
9118: <li>
9119: <p>If your package installs files into a texmf
9120: tree other than the one
9121: at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
9122: set <code class="varname">TEXMFDIRS</code> to the list of all texmf
9123: trees that need database update.</p>
9124: <p>If your package also installs font map files that need
1.10 hubertf 9125: to be registered using <span class="command"><strong>updmap</strong></span>,
1.1 dsieger 9126: set <code class="varname">TEX_FONTMAPS</code> to the list of all
1.10 hubertf 9127: such font map files. Then <span class="command"><strong>updmap</strong></span> will
1.1 dsieger 9128: be run automatically at installation/deinstallation to
9129: enable/disable font map files for TeX output
9130: drivers.</p>
9131: </li>
9132: <li><p>Make sure that none of <code class="filename">ls-R</code>
9133: databases are included in <code class="filename">PLIST</code>, as
9134: they will be removed only by the teTeX-bin package.</p></li>
9135: </ol></div>
9136: </div>
9137: <div class="sect2" lang="en">
9138: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 9139: <a name="emulation-packages"></a>19.6.18. Packages supporting running binaries in
1.1 dsieger 9140: emulation</h3></div></div></div>
9141: <p>There are some packages that provide libraries and
9142: executables for running binaries from a one operating system
9143: on a different one (if the latter supports it). One example
9144: is running Linux binaries on NetBSD.</p>
9145: <p>The <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/rpm2pkg/README.html" target="_top"><code class="filename">pkgtools/rpm2pkg</code></a>
9146: helps in extracting and packaging Linux rpm packages.</p>
9147: <p>The <code class="varname">CHECK_SHLIBS</code> can be set to no to
1.10 hubertf 9148: avoid the <span class="command"><strong>check-shlibs</strong></span> target, which tests
1.1 dsieger 9149: if all libraries for each installed executable can be found by
9150: the dynamic linker. Since the standard dynamic linker is run,
9151: this fails for emulation packages, because the libraries used
9152: by the emulation are not in the standard directories.</p>
9153: </div>
9154: <div class="sect2" lang="en">
9155: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 9156: <a name="hicolor-theme"></a>19.6.19. Packages installing hicolor theme icons</h3></div></div></div>
1.1 dsieger 9157: <p>If a package installs images under the
9158: <code class="filename">share/icons/hicolor</code> and/or updates the
9159: <code class="filename">share/icons/hicolor/icon-theme.cache</code>
9160: database, you need to take some extra steps to make sure that the
9161: shared theme directory is handled appropriately and that the cache
9162: database is rebuilt:</p>
9163: <div class="orderedlist"><ol type="1">
9164: <li><p>Include
9165: <code class="filename">../../graphics/hicolor-icon-theme/buildlink3.mk</code>.</p></li>
9166: <li><p>Check the <code class="filename">PLIST</code> and remove the
9167: entry that refers to the theme cache.</p></li>
9168: <li><p>Ensure that the PLIST does not remove the shared icon
9169: directories from the <code class="filename">share/icons/hicolor</code>
9170: hierarchy because they will be handled automatically.</p></li>
9171: </ol></div>
9172: <p>The best way to verify that the PLIST is correct with
9173: respect to the last two points is to regenerate it using
1.10 hubertf 9174: <span class="command"><strong>make print-PLIST</strong></span>.</p>
1.1 dsieger 9175: </div>
9176: <div class="sect2" lang="en">
9177: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 9178: <a name="desktop-files"></a>19.6.20. Packages installing desktop files</h3></div></div></div>
1.1 dsieger 9179: <p>If a package installs <code class="filename">.desktop</code> files
9180: under <code class="filename">share/applications</code> and these include
9181: MIME information, you need to take extra steps to ensure that they
9182: are registered into the MIME database:</p>
9183: <div class="orderedlist"><ol type="1">
9184: <li><p>Include
9185: <code class="filename">../../sysutils/desktop-file-utils/desktopdb.mk</code>.</p></li>
9186: <li><p>Check the PLIST and remove the entry that refers to the
9187: <code class="filename">share/applications/mimeinfo.cache</code> file.
9188: It will be handled automatically.</p></li>
9189: </ol></div>
9190: <p>The best way to verify that the PLIST is correct with
1.10 hubertf 9191: respect to the last point is to regenerate it using <span class="command"><strong>make
1.1 dsieger 9192: print-PLIST</strong></span>.</p>
9193: </div>
9194: </div>
9195: <div class="sect1" lang="en">
9196: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 9197: <a name="punting"></a>19.7. Marking packages as having problems</h2></div></div></div>
1.1 dsieger 9198: <p>In some cases one does not have the time to solve a problem
9199: immediately. There are currently two ways to declare that one knows
9200: that a package has problems.</p>
9201: <div class="itemizedlist"><ul type="disc">
9202: <li><p>The first way is to plainly mark it as broken. For
9203: this, one just sets the variable <code class="varname">BROKEN</code> to the
9204: reason why the package is broken (similar to the
9205: <code class="varname">RESTRICTED</code> variable). A user trying to build
9206: the package will immediately be shown this message, and the build
9207: will not be even tried.</p></li>
9208: <li><p>After each pkgsrc freeze period (a time when the
9209: tree is stabilized and a new pkgsrc branch is cut), the packages
9210: that were not building in the official branch build on the latest
9211: NetBSD release will be marked as broken on that branch. This is
9212: done by setting the <code class="varname">BROKEN_IN</code> variable to the
9213: branch name (or appending the branch name to it). If a user tries
9214: to build such a package and the build fails, the user gets a
9215: message that says that the package was broken on the respective
9216: branch(es).</p></li>
9217: </ul></div>
9218: <p>Both types of packages are removed from pkgsrc in irregular
9219: intervals.</p>
9220: </div>
9221: </div>
9222: <div class="chapter" lang="en">
9223: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 9224: <a name="debug"></a>Chapter 20. Debugging</h2></div></div></div>
1.1 dsieger 9225: <p>To check out all the gotchas when building a package, here are
9226: the steps that I do in order to get a package working. Please note
9227: this is basically the same as what was explained in the previous
9228: sections, only with some debugging aids.</p>
9229: <div class="itemizedlist"><ul type="disc">
1.10 hubertf 9230: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=yes</code> in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.</p></li>
1.1 dsieger 9231: <li>
9232: <p>Install <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a>,
9233: create a directory for a new package, change into it, then run
1.10 hubertf 9234: <span class="command"><strong>url2pkg</strong></span>:</p>
1.1 dsieger 9235: <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>
9236: <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>
9237: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
9238: </li>
9239: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
9240: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.10 hubertf 9241: <li><p>Run <span class="command"><strong>make configure</strong></span></p></li>
1.1 dsieger 9242: <li><p>Add any dependencies glimpsed from documentation and the
9243: configure step to the package's
9244: <code class="filename">Makefile</code>.</p></li>
9245: <li>
9246: <p>Make the package compile, doing multiple rounds of</p>
9247: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
9248: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
9249: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
9250: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
9251: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
9252: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
9253: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
9254: <p>Doing this step as non-root user will ensure that no files
9255: are modified that shouldn't be, especially during the build
1.10 hubertf 9256: phase. <span class="command"><strong>mkpatches</strong></span>,
9257: <span class="command"><strong>patchdiff</strong></span> and <span class="command"><strong>pkgvi</strong></span> are
1.1 dsieger 9258: from the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a>
9259: package.</p>
9260: </li>
9261: <li><p>Look at the <code class="filename">Makefile</code>, fix if
1.10 hubertf 9262: necessary; see <a class="xref" href="#components.Makefile" title="11.1. Makefile">Section 11.1, “<code class="filename">Makefile</code>”</a>.</p></li>
1.1 dsieger 9263: <li>
9264: <p>Generate a <code class="filename">PLIST</code>:</p>
9265: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
9266: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST >PLIST</code></strong>
9267: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
9268: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
9269: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
9270: <p>You usually need to be <code class="username">root</code> to do
9271: this. Look if there are any files left:</p>
9272: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
9273: <p>If this reveals any files that are missing in
9274: <code class="filename">PLIST</code>, add them.</p>
9275: </li>
9276: <li>
9277: <p>Now that the <code class="filename">PLIST</code> is OK, install the
9278: package again and make a binary package:</p>
9279: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
9280: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
9281: </li>
9282: <li>
9283: <p>Delete the installed package:</p>
9284: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete <em class="replaceable"><code>examplepkg</code></em></code></strong></pre>
9285: </li>
9286: <li>
1.10 hubertf 9287: <p>Repeat the above <span class="command"><strong>make print-PLIST</strong></span>
1.1 dsieger 9288: command, which shouldn't find anything now:</p>
9289: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
9290: </li>
9291: <li>
9292: <p>Reinstall the binary package:</p>
9293: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add .../<em class="replaceable"><code>examplepkg</code></em>.tgz</code></strong></pre>
9294: </li>
9295: <li><p>Play with it. Make sure everything works.</p></li>
9296: <li>
1.10 hubertf 9297: <p>Run <span class="command"><strong>pkglint</strong></span> from <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>, and fix the problems it
1.1 dsieger 9298: reports:</p>
9299: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
9300: </li>
1.10 hubertf 9301: <li><p>Submit (or commit, if you have cvs access); see <a class="xref" href="#submit" title="Chapter 21. Submitting and Committing">Chapter 21, <i>Submitting and Committing</i></a>.</p></li>
1.1 dsieger 9302: </ul></div>
9303: </div>
9304: <div class="chapter" lang="en">
9305: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 9306: <a name="submit"></a>Chapter 21. Submitting and Committing</h2></div></div></div>
1.1 dsieger 9307: <div class="toc">
9308: <p><b>Table of Contents</b></p>
9309: <dl>
1.6 rillig 9310: <dt><span class="sect1"><a href="#submitting-binary-packages">21.1. Submitting binary packages</a></span></dt>
9311: <dt><span class="sect1"><a href="#submitting-your-package">21.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
9312: <dt><span class="sect1"><a href="#general-notes-for-changes">21.3. General notes when adding, updating, or removing packages</a></span></dt>
9313: <dt><span class="sect1"><a href="#committing-importing">21.4. Committing: Importing a package into CVS</a></span></dt>
9314: <dt><span class="sect1"><a href="#updating-package">21.5. Updating a package to a newer version</a></span></dt>
9315: <dt><span class="sect1"><a href="#moving-package">21.6. Moving a package in pkgsrc</a></span></dt>
1.1 dsieger 9316: </dl>
9317: </div>
9318: <div class="sect1" lang="en">
9319: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 9320: <a name="submitting-binary-packages"></a>21.1. Submitting binary packages</h2></div></div></div>
1.1 dsieger 9321: <p>Our policy is that we accept binaries only from pkgsrc
9322: developers to guarantee that the packages don't contain any
9323: trojan horses etc. This is not to annoy anyone but rather to
9324: protect our users! You're still free to put up your home-made
9325: binary packages and tell the world where to get them. NetBSD
9326: developers doing bulk builds and wanting to upload them please
1.10 hubertf 9327: see <a class="xref" href="#bulk-upload" title="7.3.8. Uploading results of a bulk build">Section 7.3.8, “Uploading results of a bulk build”</a>.</p>
1.1 dsieger 9328: </div>
9329: <div class="sect1" lang="en">
9330: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 9331: <a name="submitting-your-package"></a>21.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
1.1 dsieger 9332: <p>First, check that your package is complete, compiles and
1.10 hubertf 9333: runs well; see <a class="xref" href="#debug" title="Chapter 20. Debugging">Chapter 20, <i>Debugging</i></a> and the rest of this
9334: document. Next, generate an uuencoded gzipped <a class="citerefentry" 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.1 dsieger 9335: archive that contains all files that make up the package.
9336: Finally, send this package to the pkgsrc bug tracking system,
1.10 hubertf 9337: either with the <a class="citerefentry" 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
1.1 dsieger 9338: that, go to the web page
1.10 hubertf 9339: <a class="ulink" href="http://www.NetBSD.org/support/send-pr.html" target="_top">http://www.NetBSD.org/support/send-pr.html</a>,
1.1 dsieger 9340: which contains some instructions and a link to a form, where you
9341: can submit packages.</p>
9342: <p>In the form of the problem report, the category should be
9343: “<span class="quote">pkg</span>”, the synopsis should include the package name
9344: and version number, and the description field should contain a
9345: short description of your package (contents of the COMMENT
9346: variable or DESCR file are OK). The uuencoded package data should
9347: go into the “<span class="quote">fix</span>” field.</p>
9348: <p>If you want to submit several packages, please send a
9349: separate PR for each one, it's easier for us to track things
9350: that way.</p>
9351: <p>Alternatively, you can also import new packages into
9352: pkgsrc-wip (“<span class="quote">pkgsrc work-in-progress</span>”); see the
1.10 hubertf 9353: homepage at <a class="ulink" href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
1.1 dsieger 9354: for details.</p>
9355: </div>
9356: <div class="sect1" lang="en">
9357: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 9358: <a name="general-notes-for-changes"></a>21.3. General notes when adding, updating, or removing packages</h2></div></div></div>
1.1 dsieger 9359: <p>Please note all package additions, updates, moves, and
9360: removals in <code class="filename">pkgsrc/doc/CHANGES-<em class="replaceable"><code>YYYY</code></em></code>. It's very
9361: important to keep this file up to date and conforming to the
9362: existing format, because it will be used by scripts to
1.10 hubertf 9363: automatically update pages on <a class="ulink" href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
1.1 dsieger 9364: sites. Additionally, check the
9365: <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
9366: for the package you updated or removed, in case it was mentioned
9367: there.</p>
9368: <p>When the <code class="varname">PKGREVISION</code> of a package is
9369: bumped, the change should appear in
9370: <code class="filename">pkgsrc/doc/CHANGES-<em class="replaceable"><code>YYYY</code></em></code> if it is security
9371: related or otherwise relevant. Mass bumps that result from a
9372: dependency being updated should not be mentioned. In all other
9373: cases it's the developer's decision.</p>
9374: <p>There is a make target that helps in creating proper
1.10 hubertf 9375: <code class="filename">CHANGES-<em class="replaceable"><code>YYYY</code></em></code> entries: <span class="command"><strong>make
1.1 dsieger 9376: changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
9377: and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
9378: usage is to first make sure that your <code class="filename">CHANGES-<em class="replaceable"><code>YYYY</code></em></code>
9379: file is up-to-date (to avoid having to resolve conflicts later-on)
1.10 hubertf 9380: and then to <span class="command"><strong>cd</strong></span> to the package directory. For
9381: package updates, <span class="command"><strong>make changes-entry</strong></span> is enough.
1.1 dsieger 9382: For new packages, or package moves or removals, set the
9383: <code class="varname">CTYPE</code> variable on the command line to "Added",
9384: "Moved", or "Removed". You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.10 hubertf 9385: in <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a> if your local login name is
1.1 dsieger 9386: not the same as your NetBSD login name. Don't forget to commit
9387: the changes to <code class="filename">pkgsrc/doc/CHANGES-<em class="replaceable"><code>YYYY</code></em></code>!</p>
9388: </div>
9389: <div class="sect1" lang="en">
9390: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 9391: <a name="committing-importing"></a>21.4. Committing: Importing a package into CVS</h2></div></div></div>
1.1 dsieger 9392: <p>This section is only of interest for pkgsrc developers with write
9393: access to the pkgsrc repository. Please remember that cvs
9394: imports files relative to the current working directory, and that
9395: the pathname that you
1.10 hubertf 9396: give the <span class="command"><strong>cvs import</strong></span> command is so that it knows where
1.1 dsieger 9397: to place the files in the repository. Newly created packages should be
9398: imported with a vendor tag of “<span class="quote">TNF</span>” and a release tag of
9399: “<span class="quote">pkgsrc-base</span>”, e.g:</p>
9400: <pre class="programlisting">
9401: <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
9402: <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
9403: </pre>
9404: <p>Remember to move the directory from which you imported out of
9405: the way, or cvs will complain the next time you “<span class="quote">cvs
9406: update</span>” your source tree. Also don't forget to add the new
9407: package to the category's <code class="filename">Makefile</code>.</p>
9408: <p>The commit message of the initial import should include part of the
9409: <code class="filename">DESCR</code> file, so people reading the mailing lists know
9410: what the package is/does.</p>
9411: <p>For new packages, “<span class="quote">cvs import</span>” is preferred to “<span class="quote">cvs
9412: add</span>” because the former gets everything with a single command,
9413: and provides a consistent tag.</p>
9414: </div>
9415: <div class="sect1" lang="en">
9416: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 9417: <a name="updating-package"></a>21.5. Updating a package to a newer version</h2></div></div></div>
1.1 dsieger 9418: <p>Please always put a concise, appropriate and relevant summary of the
9419: changes between old and new versions into the commit log when updating
9420: a package. There are various reasons for this:</p>
9421: <div class="itemizedlist"><ul type="disc">
9422: <li><p>A URL is volatile, and can change over time. It may go away completely
9423: or its information may be overwritten by newer information.</p></li>
9424: <li><p>Having the change information between old and new versions in our CVS
9425: repository is very useful for people who use either cvs or anoncvs.</p></li>
9426: <li><p>Having the change information between old and new versions in our CVS
9427: repository is very useful for people who read the pkgsrc-changes mailing
9428: list, so that they can make tactical decisions about when to upgrade
9429: the package.</p></li>
9430: </ul></div>
9431: <p>Please also recognize that, just because a new version of a package
9432: has been released, it should not automatically be upgraded in the CVS
9433: repository. We prefer to be conservative in the packages that are
9434: included in pkgsrc - development or beta packages are not really the
9435: best thing for most places in which pkgsrc is used. Please use your
9436: judgement about what should go into pkgsrc, and bear in mind that
9437: stability is to be preferred above new and possibly untested features.</p>
9438: </div>
9439: <div class="sect1" lang="en">
9440: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 9441: <a name="moving-package"></a>21.6. Moving a package in pkgsrc</h2></div></div></div>
1.1 dsieger 9442: <div class="orderedlist"><ol type="1">
9443: <li><p>Make a copy of the directory somewhere else.</p></li>
9444: <li>
9445: <p>Remove all CVS dirs.</p>
9446: <p>Alternatively to the first two steps you can also do:</p>
9447: <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>
9448: <p>and use that for further work.</p>
9449: </li>
9450: <li><p>Fix <code class="varname">CATEGORIES</code> and any
9451: <code class="varname">DEPENDS</code> paths that just did “<span class="quote">../package</span>”
9452: instead of “<span class="quote">../../category/package</span>”.</p></li>
1.10 hubertf 9453: <li><p><span class="command"><strong>cvs import</strong></span> the modified package in the new
1.1 dsieger 9454: place.</p></li>
9455: <li>
9456: <p>Check if any package depends on it:
9457: </p>
9458: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
9459: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
9460: </li>
9461: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
1.10 hubertf 9462: <li><p><span class="command"><strong>cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.1 dsieger 9463: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
9464: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
9465: <li>
9466: <p>Commit the changed and removed files:</p>
9467: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong></pre>
9468: <p>(and any packages from step 5, of course).</p>
9469: </li>
9470: </ol></div>
9471: </div>
9472: </div>
9473: <div class="chapter" lang="en">
9474: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 9475: <a name="devfaq"></a>Chapter 22. Frequently Asked Questions</h2></div></div></div>
1.1 dsieger 9476: <p>This section contains the answers to questions that may
9477: arise when you are writing a package. If you don't find your
9478: question answered here, first have a look in the other chapters,
9479: and if you still don't have the answer, ask on the
9480: <code class="literal">pkgsrc-users</code> mailing list.</p>
9481: <div class="qandaset">
9482: <dl>
1.6 rillig 9483: <dt>22.1. <a href="#devfaq.makeflags">What is the difference between
1.1 dsieger 9484: MAKEFLAGS, .MAKEFLAGS and
9485: MAKE_FLAGS?</a>
9486: </dt>
1.6 rillig 9487: <dt>22.2. <a href="#devfaq.make">What is the difference between
1.1 dsieger 9488: MAKE, GMAKE and
9489: MAKE_PROGRAM?</a>
9490: </dt>
1.6 rillig 9491: <dt>22.3. <a href="#devfaq.cc">What is the difference between
1.1 dsieger 9492: CC, PKG_CC and
9493: PKGSRC_COMPILER?</a>
9494: </dt>
1.6 rillig 9495: <dt>22.4. <a href="#devfaq.bl3flags">What is the difference between
1.1 dsieger 9496: BUILDLINK_LDFLAGS,
9497: BUILDLINK_LDADD and
9498: BUILDLINK_LIBS?</a>
9499: </dt>
1.6 rillig 9500: <dt>22.5. <a href="#devfaq.bl3prefix">Why does make show-var
1.1 dsieger 9501: VARNAME=BUILDLINK_PREFIX.foo
9502: say it's empty?</a>
9503: </dt>
1.6 rillig 9504: <dt>22.6. <a href="#devfaq.master_sites">What does
1.1 dsieger 9505: ${MASTER_SITE_SOURCEFORGE:=package/} mean? I
9506: don't understand the := inside
9507: it.</a>
9508: </dt>
1.6 rillig 9509: <dt>22.7. <a href="#devfaq.mailinglists">Which mailing lists are there for package
1.1 dsieger 9510: developers?</a>
9511: </dt>
1.6 rillig 9512: <dt>22.8. <a href="#devfaq.documentation">Where is the pkgsrc
1.1 dsieger 9513: documentation?</a>
9514: </dt>
1.6 rillig 9515: <dt>22.9. <a href="#devfaq.too-much-time">I have a little time to kill. What shall I
1.1 dsieger 9516: do?</a>
9517: </dt>
9518: </dl>
9519: <table border="0" summary="Q and A Set">
9520: <col align="left" width="1%">
9521: <tbody>
9522: <tr class="question">
9523: <td align="left" valign="top">
1.14 ! jmcneill 9524: <a name="devfaq.makeflags"></a><a name="id1168230233435"></a><p><b>22.1.</b></p>
1.1 dsieger 9525: </td>
9526: <td align="left" valign="top"><p>What is the difference between
9527: <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
9528: <code class="varname">MAKE_FLAGS</code>?</p></td>
9529: </tr>
9530: <tr class="answer">
9531: <td align="left" valign="top"></td>
9532: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
1.10 hubertf 9533: to the pkgsrc-internal invocations of <a class="citerefentry" 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
1.1 dsieger 9534: <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
9535: the <code class="varname">MAKE_PROGRAM</code> when building the
9536: package. [FIXME: What is .MAKEFLAGS for?]</p></td>
9537: </tr>
9538: <tr class="question">
9539: <td align="left" valign="top">
1.14 ! jmcneill 9540: <a name="devfaq.make"></a><a name="id1168230233468"></a><p><b>22.2.</b></p>
1.1 dsieger 9541: </td>
9542: <td align="left" valign="top"><p>What is the difference between
9543: <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
9544: <code class="varname">MAKE_PROGRAM</code>?</p></td>
9545: </tr>
9546: <tr class="answer">
9547: <td align="left" valign="top"></td>
9548: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
1.10 hubertf 9549: <a class="citerefentry" 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
1.1 dsieger 9550: infrastructure. <code class="varname">GMAKE</code> is the path to GNU
9551: Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
9552: use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
9553: Make program that is used for building the
9554: package.</p></td>
9555: </tr>
9556: <tr class="question">
9557: <td align="left" valign="top">
1.14 ! jmcneill 9558: <a name="devfaq.cc"></a><a name="id1168230233574"></a><p><b>22.3.</b></p>
1.1 dsieger 9559: </td>
9560: <td align="left" valign="top"><p>What is the difference between
9561: <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
9562: <code class="varname">PKGSRC_COMPILER</code>?</p></td>
9563: </tr>
9564: <tr class="answer">
9565: <td align="left" valign="top"></td>
9566: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
9567: compiler, which can be configured by the pkgsrc user.
9568: <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
9569: <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
9570: path to a compiler, but the type of compiler that should be
9571: used. See <code class="filename">mk/compiler.mk</code> for more
9572: information about the latter variable.</p></td>
9573: </tr>
9574: <tr class="question">
9575: <td align="left" valign="top">
1.14 ! jmcneill 9576: <a name="devfaq.bl3flags"></a><a name="id1168230233608"></a><p><b>22.4.</b></p>
1.1 dsieger 9577: </td>
9578: <td align="left" valign="top"><p>What is the difference between
9579: <code class="varname">BUILDLINK_LDFLAGS</code>,
9580: <code class="varname">BUILDLINK_LDADD</code> and
9581: <code class="varname">BUILDLINK_LIBS</code>?</p></td>
9582: </tr>
9583: <tr class="answer">
9584: <td align="left" valign="top"></td>
9585: <td align="left" valign="top"><p>[FIXME]</p></td>
9586: </tr>
9587: <tr class="question">
9588: <td align="left" valign="top">
1.14 ! jmcneill 9589: <a name="devfaq.bl3prefix"></a><a name="id1168230233626"></a><p><b>22.5.</b></p>
1.1 dsieger 9590: </td>
1.10 hubertf 9591: <td align="left" valign="top"><p>Why does <span class="command"><strong>make show-var
1.1 dsieger 9592: VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
9593: say it's empty?</p></td>
9594: </tr>
9595: <tr class="answer">
9596: <td align="left" valign="top"></td>
9597: <td align="left" valign="top"><p>For optimization reasons, some variables are only
9598: available in the “<span class="quote">wrapper</span>” phase and later. To
9599: “<span class="quote">simulate</span>” the wrapper phase, append
1.10 hubertf 9600: <span class="command"><strong>PKG_PHASE=wrapper</strong></span> to the above
1.1 dsieger 9601: command.</p></td>
9602: </tr>
9603: <tr class="question">
9604: <td align="left" valign="top">
1.14 ! jmcneill 9605: <a name="devfaq.master_sites"></a><a name="id1168230233653"></a><p><b>22.6.</b></p>
1.1 dsieger 9606: </td>
9607: <td align="left" valign="top"><p>What does
9608: <code class="literal">${MASTER_SITE_SOURCEFORGE:=package/}</code> mean? I
9609: don't understand the <code class="literal">:=</code> inside
9610: it.</p></td>
9611: </tr>
9612: <tr class="answer">
9613: <td align="left" valign="top"></td>
9614: <td align="left" valign="top"><p>The <code class="literal">:=</code> is not really an
9615: assignment operator, like you might expect at first sight.
9616: Instead, it is a degenerate form of
9617: <code class="literal">${LIST:<em class="replaceable"><code>old_string</code></em>=<em class="replaceable"><code>new_string</code></em>}</code>,
1.10 hubertf 9618: which is documented in the <a class="citerefentry" 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
1.1 dsieger 9619: may have seen as in <code class="literal">${SRCS:.c=.o}</code>. In the
9620: case of <code class="varname">MASTER_SITE_*</code>,
9621: <em class="replaceable"><code>old_string</code></em> is the empty string and
9622: <em class="replaceable"><code>new_string</code></em> is
9623: <code class="literal">package/</code>. That's where the
9624: <code class="literal">:</code> and the <code class="literal">=</code> fall
9625: together.</p></td>
9626: </tr>
9627: <tr class="question">
9628: <td align="left" valign="top">
1.14 ! jmcneill 9629: <a name="devfaq.mailinglists"></a><a name="id1168230233720"></a><p><b>22.7.</b></p>
1.1 dsieger 9630: </td>
9631: <td align="left" valign="top"><p>Which mailing lists are there for package
9632: developers?</p></td>
9633: </tr>
9634: <tr class="answer">
9635: <td align="left" valign="top"></td>
9636: <td align="left" valign="top"><div class="variablelist"><dl>
1.10 hubertf 9637: <dt><span class="term"><a class="ulink" href="http://www.NetBSD.org/mailinglists/index.html#tech-pkg" target="_top">tech-pkg</a></span></dt>
1.1 dsieger 9638: <dd><p>This is a list for technical discussions related
9639: to pkgsrc development, e.g. soliciting feedback for changes to
9640: pkgsrc infrastructure, proposed new features, questions related
9641: to porting pkgsrc to a new platform, advice for maintaining a
9642: package, patches that affect many packages, help requests moved
9643: from pkgsrc-users when an infrastructure bug is found,
9644: etc.</p></dd>
1.10 hubertf 9645: <dt><span class="term"><a class="ulink" href="http://www.NetBSD.org/mailinglists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a></span></dt>
1.1 dsieger 9646: <dd><p>All bug reports in category "pkg" sent with
1.10 hubertf 9647: <a class="citerefentry" 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
1.1 dsieger 9648: directly; use one of the other mailing
9649: lists.</p></dd>
9650: </dl></div></td>
9651: </tr>
9652: <tr class="question">
9653: <td align="left" valign="top">
1.14 ! jmcneill 9654: <a name="devfaq.documentation"></a><a name="id1168230233751"></a><p><b>22.8.</b></p>
1.1 dsieger 9655: </td>
9656: <td align="left" valign="top"><p>Where is the pkgsrc
9657: documentation?</p></td>
9658: </tr>
9659: <tr class="answer">
9660: <td align="left" valign="top"></td>
9661: <td align="left" valign="top">
9662: <p>There are many places where you can find
9663: documentation about pkgsrc:</p>
9664: <div class="itemizedlist"><ul type="disc">
9665: <li><p>The pkgsrc guide (this document) is a collection
9666: of chapters that explain large parts of pkgsrc, but some
9667: chapters tend to be outdated. Which ones they are is hard to
9668: say.</p></li>
1.10 hubertf 9669: <li><p>On the mailing list archives (see <a class="ulink" href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>), you can find discussions
1.1 dsieger 9670: about certain features, announcements of new parts of the pkgsrc
9671: infrastructure and sometimes even announcements that a certain
9672: feature has been marked as obsolete. The benefit here is that
9673: each message has a date appended to it.</p></li>
9674: <li><p>Many of the files in the
9675: <code class="filename">mk/</code> directory start with a comment that
9676: describes the purpose of the file and how it can be used by the
9677: pkgsrc user and package authors. An easy way to find this
1.10 hubertf 9678: documentation is to run <span class="command"><strong>bmake
1.1 dsieger 9679: help</strong></span>.</p></li>
9680: <li><p>The CVS log messages are a rich source of
9681: information, but they tend to be highly abbreviated, especially
9682: for actions that occur often. Some contain a detailed
9683: description of what has changed, but they are geared towards the
9684: other pkgsrc developers, not towards an average pkgsrc user.
9685: They also only document <span class="emphasis"><em>changes</em></span>, so if you
9686: don't know what has been before, these messages may not be worth
9687: too much to you.</p></li>
9688: <li><p>Some parts of pkgsrc are only “<span class="quote">implicitly
9689: documented</span>”, that is the documentation exists only in the
9690: mind of the developer who wrote the code. To get this
1.10 hubertf 9691: information, use the <span class="command"><strong>cvs annotate</strong></span> command
1.1 dsieger 9692: to see who has written it and ask on the
9693: <code class="literal">tech-pkg</code> mailing list, so that others can
9694: find your questions later (see above). To be sure that the
9695: developer in charge reads the mail, you may CC him or
9696: her.</p></li>
9697: </ul></div>
9698: </td>
9699: </tr>
9700: <tr class="question">
9701: <td align="left" valign="top">
1.14 ! jmcneill 9702: <a name="devfaq.too-much-time"></a><a name="id1168230233805"></a><p><b>22.9.</b></p>
1.1 dsieger 9703: </td>
9704: <td align="left" valign="top"><p>I have a little time to kill. What shall I
9705: do?</p></td>
9706: </tr>
9707: <tr class="answer">
9708: <td align="left" valign="top"></td>
9709: <td align="left" valign="top">
9710: <p>This is not really an FAQ yet, but here's the answer
9711: anyway.</p>
9712: <div class="itemizedlist"><ul type="disc">
1.10 hubertf 9713: <li><p>Run <span class="command"><strong>pkg_chk -N</strong></span> (from the
1.1 dsieger 9714: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_chk/README.html" target="_top"><code class="filename">pkgtools/pkg_chk</code></a> package). It
9715: will tell you about newer versions of installed packages that are
9716: available, but not yet updated in pkgsrc.</p></li>
9717: <li><p>Browse <code class="filename">pkgsrc/doc/TODO</code>
1.14 ! jmcneill 9718: — it contains a list of suggested new packages and a list of
1.1 dsieger 9719: cleanups and enhancements for pkgsrc that would be nice to
9720: have.</p></li>
9721: <li><p>Review packages for which review was requested on
1.10 hubertf 9722: the <a class="ulink" href="http://pkgsrc-wip.sourceforge.net/" target="_top">pkgsrc-wip</a> review
1.1 dsieger 9723: mailing list.</p></li>
9724: </ul></div>
9725: </td>
9726: </tr>
9727: </tbody>
9728: </table>
9729: </div>
9730: </div>
9731: <div class="chapter" lang="en">
9732: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 9733: <a name="gnome"></a>Chapter 23. GNOME packaging and porting</h2></div></div></div>
1.1 dsieger 9734: <div class="toc">
9735: <p><b>Table of Contents</b></p>
9736: <dl>
1.6 rillig 9737: <dt><span class="sect1"><a href="#meta-packages">23.1. Meta packages</a></span></dt>
9738: <dt><span class="sect1"><a href="#new-package">23.2. Packaging a GNOME application</a></span></dt>
9739: <dt><span class="sect1"><a href="#full-update">23.3. Updating GNOME to a newer version</a></span></dt>
9740: <dt><span class="sect1"><a href="#patching">23.4. Patching guidelines</a></span></dt>
1.1 dsieger 9741: </dl>
9742: </div>
1.10 hubertf 9743: <p>Quoting <a class="ulink" href="http://www.gnome.org/" target="_top">GNOME's web
1.1 dsieger 9744: site</a>:</p>
9745: <div class="blockquote"><blockquote class="blockquote"><p>The GNOME project provides two things: The GNOME desktop
9746: environment, an intuitive and attractive desktop for users, and the
9747: GNOME development platform, an extensive framework for building
9748: applications that integrate into the rest of the desktop.</p></blockquote></div>
9749: <p>pkgsrc provides a seamless way to automatically build and install
9750: a complete GNOME environment <span class="emphasis"><em>under many different
9751: platforms</em></span>. We can say with confidence that pkgsrc is one of
9752: the most advanced build and packaging systems for GNOME due to its
9753: included technologies buildlink3, the wrappers and tools framework and
9754: automatic configuration file management. Lots of efforts are put into
9755: achieving a completely clean deinstallation of installed software
9756: components.</p>
1.10 hubertf 9757: <p>Given that pkgsrc is <a class="ulink" href="http://www.NetBSD.org/" target="_top">NetBSD</a>'s official packaging system,
1.1 dsieger 9758: the above also means that great efforts are put into making GNOME work
1.10 hubertf 9759: under this operating system. Recently, <a class="ulink" href="http://www.dragonflybsd.org/" target="_top">DragonFly BSD</a> also adopted
1.1 dsieger 9760: pkgsrc as its preferred packaging system, contributing lots of
9761: portability fixes to make GNOME build and install under it.</p>
9762: <p>This chapter is aimed at pkgsrc developers and other people
9763: interested in helping our GNOME porting and packaging efforts. It
9764: provides instructions on how to manage the existing packages and some
9765: important information regarding their internals.</p>
9766: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
9767: <h3 class="title">We need your help!</h3>
9768: <p>Should you have some spare cycles to devote to NetBSD, pkgsrc
9769: and GNOME and are willing to learn new exciting stuff, please jump
1.10 hubertf 9770: straight to the <a class="ulink" href="http://www.NetBSD.org/contrib/projects.html#gnome" target="_top">pending
1.1 dsieger 9771: work</a> list! There is still a long way to go to get a
9772: fully-functional GNOME desktop under NetBSD and we need your help to
9773: achieve it!</p>
9774: </div>
9775: <div class="sect1" lang="en">
9776: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 9777: <a name="meta-packages"></a>23.1. Meta packages</h2></div></div></div>
1.1 dsieger 9778: <p>pkgsrc includes three GNOME-related meta packages:</p>
9779: <div class="itemizedlist"><ul type="disc">
9780: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome-base/README.html" target="_top"><code class="filename">meta-pkgs/gnome-base</code></a>: Provides
9781: the core GNOME desktop environment. It only includes the necessary
9782: bits to get it to boot correctly, although it may lack important
9783: functionality for daily operation. The idea behind this package is
9784: to let end users build their own configurations on top of this one,
9785: first installing this meta package to achieve a functional setup and
9786: then adding individual applications.</p></li>
9787: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome/README.html" target="_top"><code class="filename">meta-pkgs/gnome</code></a>: Provides a
9788: complete installation of the GNOME platform and desktop as defined
9789: by the GNOME project; this is based on the components distributed in
9790: the <code class="filename">platform/x.y/x.y.z/sources</code> and
9791: <code class="filename">desktop/x.y/x.y.z/sources</code> directories of the
9792: official FTP server. Developer-only tools found in those
9793: directories are not installed unless required by some other
9794: component to work properly. Similarly, packages from the bindings
9795: set (<code class="filename">bindings/x.y/x.y.z/sources</code>) are not pulled
9796: in unless required as a dependency for an end-user component. This
9797: package "extends" <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome-base/README.html" target="_top"><code class="filename">meta-pkgs/gnome-base</code></a>.</p></li>
9798: <li><p><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome-devel/README.html" target="_top"><code class="filename">meta-pkgs/gnome-devel</code></a>:
9799: Installs all the tools required to build a GNOME component when
9800: fetched from the CVS repository. These are required to let the
1.10 hubertf 9801: <span class="command"><strong>autogen.sh</strong></span> scripts work appropriately.</p></li>
1.1 dsieger 9802: </ul></div>
9803: <p>In all these packages, the <code class="varname">DEPENDS</code> lines are
9804: sorted in a way that eases updates: a package may depend on other
9805: packages listed before it but not on any listed after it. It is very
9806: important to keep this order to ease updates so... <span class="emphasis"><em>do not
9807: change it to alphabetical sorting!</em></span></p>
9808: </div>
9809: <div class="sect1" lang="en">
9810: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 9811: <a name="new-package"></a>23.2. Packaging a GNOME application</h2></div></div></div>
1.1 dsieger 9812: <p>Almost all GNOME applications are written in C and use a common
9813: set of tools as their build system. Things get different with the new
9814: bindings to other languages (such as Python), but the following will
9815: give you a general idea on the minimum required tools:</p>
9816: <div class="itemizedlist"><ul type="disc">
9817: <li>
9818: <p>Almost all GNOME applications use the GNU Autotools as their
9819: build system. As a general rule you will need to tell this to your
9820: package:</p>
9821: <pre class="programlisting">
9822: GNU_CONFIGURE=yes
9823: USE_LIBTOOL=yes
9824: USE_TOOLS+=gmake
9825: </pre>
9826: </li>
9827: <li>
9828: <p>If the package uses pkg-config to detect dependencies, add this
9829: tool to the list of required utilities:</p>
9830: <pre class="programlisting">USE_TOOLS+=pkg-config</pre>
9831: <p>Also use <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/verifypc/README.html" target="_top"><code class="filename">pkgtools/verifypc</code></a> at
9832: the end of the build process to ensure that you did not miss to
9833: specify any dependency in your package and that the version
9834: requirements are all correct.</p>
9835: </li>
9836: <li><p>If the package uses intltool, be sure to add
9837: <code class="literal">intltool</code> to the <code class="varname">USE_TOOLS</code>
9838: to handle dependencies and to force the package to use the latest
9839: available version.</p></li>
9840: <li>
9841: <p>If the package uses gtk-doc (a documentation generation
9842: utility), do <span class="emphasis"><em>not</em></span> add a dependency on it. The
9843: tool is rather big and the distfile should come with pregenerated
9844: documentation anyway; if it does not, it is a bug that you ought to
9845: report. For such packages you should disable gtk-doc (unless it is
9846: the default):</p>
9847: <pre class="programlisting">CONFIGURE_ARGS+=--disable-gtk-doc</pre>
9848: <p>The default location of installed HTML files
9849: (<code class="filename">share/gtk-doc/<package-name></code>) is correct
9850: and should not be changed unless the package insists on installing
9851: them somewhere else. Otherwise programs as
1.10 hubertf 9852: <span class="command"><strong>devhelp</strong></span> will not be able to open them. You can
1.1 dsieger 9853: do that with an entry similar to:</p>
9854: <pre class="programlisting">CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...</pre>
9855: </li>
9856: </ul></div>
9857: <p>GNOME uses multiple <span class="emphasis"><em>shared</em></span> directories and
9858: files under the installation prefix to maintain databases. In this
9859: context, shared means that those exact same directories and files are
9860: used among several different packages, leading to conflicts in the
9861: <code class="filename">PLIST</code>. pkgsrc currently includes functionality to
9862: handle the most common cases, so you have to forget about using
9863: <code class="literal">@unexec ${RMDIR}</code> lines in your file lists and
9864: omitting shared files from them. If you find yourself doing those,
9865: <span class="emphasis"><em>your package is most likely incorrect</em></span>.</p>
9866: <p>The following table lists the common situations that result in
9867: using shared directories or files. For each of them, the appropriate
9868: solution is given. After applying the solution be sure to
9869: <span class="emphasis"><em>regenerate the package's file list</em></span> with
1.10 hubertf 9870: <span class="command"><strong>make print-PLIST</strong></span> and ensure it is correct.</p>
1.1 dsieger 9871: <div class="table">
1.6 rillig 9872: <a name="plist-handling"></a><p class="title"><b>Table 23.1. PLIST handling for GNOME packages</b></p>
1.1 dsieger 9873: <div class="table-contents"><table summary="PLIST handling for GNOME packages" border="1">
9874: <colgroup>
9875: <col>
9876: <col>
9877: </colgroup>
9878: <thead><tr>
9879: <th>If the package...</th>
9880: <th>Then...</th>
9881: </tr></thead>
9882: <tbody>
9883: <tr>
9884: <td>Installs OMF files under <code class="filename">share/omf</code>.</td>
1.10 hubertf 9885: <td>See <a class="xref" href="#scrollkeeper-data-files" title="19.6.10. Packages installing scrollkeeper data files">Section 19.6.10, “Packages installing scrollkeeper data files”</a>.</td>
1.1 dsieger 9886: </tr>
9887: <tr>
9888: <td>Installs icons under the
9889: <code class="filename">share/icons/hicolor</code> hierarchy or updates
9890: <code class="filename">share/icons/hicolor/icon-theme.cache</code>.</td>
1.10 hubertf 9891: <td>See <a class="xref" href="#hicolor-theme" title="19.6.19. Packages installing hicolor theme icons">Section 19.6.19, “Packages installing hicolor theme icons”</a>.</td>
1.1 dsieger 9892: </tr>
9893: <tr>
9894: <td>Installs files under
9895: <code class="filename">share/mime/packages</code>.</td>
1.10 hubertf 9896: <td>See <a class="xref" href="#mime-database" title="19.6.14. Packages installing extensions to the MIME database">Section 19.6.14, “Packages installing extensions to the MIME database”</a>.</td>
1.1 dsieger 9897: </tr>
9898: <tr>
9899: <td>Installs <code class="filename">.desktop</code> files under
9900: <code class="filename">share/applications</code> and these include MIME
9901: information.</td>
1.10 hubertf 9902: <td>See <a class="xref" href="#desktop-files" title="19.6.20. Packages installing desktop files">Section 19.6.20, “Packages installing desktop files”</a>.</td>
1.1 dsieger 9903: </tr>
9904: </tbody>
9905: </table></div>
9906: </div>
9907: <br class="table-break">
9908: </div>
9909: <div class="sect1" lang="en">
9910: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 9911: <a name="full-update"></a>23.3. Updating GNOME to a newer version</h2></div></div></div>
1.1 dsieger 9912: <p>When seeing GNOME as a whole, there are two kinds of
9913: updates:</p>
9914: <div class="variablelist"><dl>
9915: <dt><span class="term">Major update</span></dt>
9916: <dd>
9917: <p>Given that there is still a very long way for GNOME 3 (if it
9918: ever appears), we consider a major update one that goes from a
9919: <code class="literal">2.X</code> version to a <code class="literal">2.Y</code> one,
9920: where <code class="literal">Y</code> is even and greater than
9921: <code class="literal">X</code>. These are hard to achieve because they
9922: introduce lots of changes in the components' code and almost all
9923: GNOME distfiles are updated to newer versions. Some of them can
9924: even break API and ABI compatibility with the previous major
9925: version series. As a result, the update needs to be done all at
9926: once to minimize breakage.</p>
9927: <p>A major update typically consists of around 80 package
9928: updates and the addition of some new ones.</p>
9929: </dd>
9930: <dt><span class="term">Minor update</span></dt>
9931: <dd>
9932: <p>We consider a minor update one that goes from a
9933: <code class="literal">2.A.X</code> version to a <code class="literal">2.A.Y</code>
9934: one where <code class="literal">Y</code> is greater than
9935: <code class="literal">X</code>. These are easy to achieve because they do
9936: not update all GNOME components, can be done in an incremental way
9937: and do not break API nor ABI compatibility.</p>
9938: <p>A minor update typically consists of around 50 package
9939: updates, although the numbers here may vary a lot.</p>
9940: </dd>
9941: </dl></div>
9942: <p>In order to update the GNOME components in pkgsrc to a new stable
9943: release (either major or minor), the following steps should be
9944: followed:</p>
9945: <div class="orderedlist"><ol type="1">
9946: <li>
9947: <p>Get a list of all the tarballs that form the new release by
9948: using the following commands. These will leave the full list of the
9949: components's distfiles into the <code class="filename">list.txt</code>
9950: file:</p>
9951: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>echo ls "*.tar.bz2" | \
9952: ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
9953: awk '{ print $9 }' >list.txt</code></strong>
9954: <code class="prompt">%</code> <strong class="userinput"><code>echo ls "*.tar.bz2" | \
9955: ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
9956: awk '{ print $9 }' >>list.txt</code></strong></pre>
9957: </li>
9958: <li><p>Open each meta package's <code class="filename">Makefile</code> and
9959: bump their version to the release you are updating them to. The
9960: three meta packages should be always consistent with versioning.
9961: Obviously remove any <code class="varname">PKGREVISION</code>s that might be
9962: in them.</p></li>
9963: <li>
9964: <p>For each meta package, update all its
9965: <code class="varname">DEPENDS</code> lines to match the latest versions as
9966: shown by the above commands. Do <span class="emphasis"><em>not</em></span> list any
9967: newer version (even if found in the FTP) because the meta packages
9968: are supposed to list the exact versions that form a specific GNOME
9969: release. Exceptions are permitted here if a newer version solves a
9970: serious issue in the overall desktop experience; these typically
9971: come in the form of a revision bump in pkgsrc, not in newer versions
9972: from the developers.</p>
9973: <p>Packages not listed in the <code class="filename">list.txt</code> file
9974: should be updated to the latest version available (if found in
9975: pkgsrc). This is the case, for example, of the dependencies on the
9976: GNU Autotools in the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/gnome-devel/README.html" target="_top"><code class="filename">meta-pkgs/gnome-devel</code></a> meta package.</p>
9977: </li>
9978: <li>
9979: <p>Generate a patch from the modified meta packages and extract the
9980: list of "new" lines. This will provide you an outline on what
9981: packages need to be updated in pkgsrc and in what order:</p>
9982: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt</code></strong></pre>
9983: </li>
9984: <li><p>For major desktop updates it is recommended to zap all your
9985: installed packages and start over from scratch at this point.</p></li>
9986: <li><p>Now comes the longest step by far: iterate over the contents
9987: of <code class="filename">todo.txt</code> and update the packages listed in
9988: it in order. For major desktop updates none of these should be
9989: committed until the entire set is completed because there are chances
9990: of breaking not-yet-updated packages.</p></li>
9991: <li><p>Once the packages are up to date and working, commit them to
9992: the tree one by one with appropriate log messages. At the end,
9993: commit the three meta package updates and all the corresponding
9994: changes to the <code class="filename">doc/CHANGES-<YEAR></code> and
9995: <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>
9996: </ol></div>
9997: </div>
9998: <div class="sect1" lang="en">
9999: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 10000: <a name="patching"></a>23.4. Patching guidelines</h2></div></div></div>
1.1 dsieger 10001: <p>GNOME is a very big component in pkgsrc which approaches 100
10002: packages. Please, it is very important that you always, always,
10003: <span class="strong"><strong>always</strong></span> feed back any portability
1.10 hubertf 10004: fixes you do to a GNOME package to the mainstream developers (see <a class="xref" href="#components.patches.feedback" title="11.3.5. Feedback to the author">Section 11.3.5, “Feedback to the author”</a>). This is the only way to get
1.1 dsieger 10005: their attention on portability issues and to ensure that future versions
10006: can be built out-of-the box on NetBSD. The less custom patches in
10007: pkgsrc, the easier further updates are. Those developers in charge of
10008: issuing major GNOME updates will be grateful if you do that.</p>
1.10 hubertf 10009: <p>The most common places to report bugs are the <a class="ulink" href="http://bugzilla.gnome.org/" target="_top">GNOME's Bugzilla</a> and the <a class="ulink" href="http://bugzilla.freedesktop.org/" target="_top">freedesktop.org's
1.1 dsieger 10010: Bugzilla</a>. Not all components use these to track bugs, but most
10011: of them do. Do not be short on your reports: always provide detailed
10012: explanations of the current failure, how it can be improved to achieve
10013: maximum portability and, if at all possible, provide a patch against CVS
10014: head. The more verbose you are, the higher chances of your patch being
10015: accepted.</p>
10016: <p>Also, please avoid using preprocessor magic to fix portability
10017: issues. While the FreeBSD GNOME people are doing a great job in porting
10018: GNOME to their operating system, the official GNOME sources are now
10019: plagued by conditionals that check for <code class="varname">__FreeBSD__</code>
10020: and similar macros. This hurts portability. Please see our patching
1.10 hubertf 10021: guidelines (<a class="xref" href="#components.patches.guidelines" title="11.3.4. Patching guidelines">Section 11.3.4, “Patching guidelines”</a>) for more
1.1 dsieger 10022: details.</p>
10023: </div>
10024: </div>
10025: </div>
10026: <div class="part" lang="en">
10027: <div class="titlepage"><div><div><h1 class="title">
10028: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
10029: <div class="partintro" lang="en">
10030: <div></div>
10031: <p>This part of the guide deals with everything
10032: from the infrastructure that is behind the interfaces described
10033: in the developer's guide. A casual package maintainer should not
10034: need anything from this part.</p>
10035: <div class="toc">
10036: <p><b>Table of Contents</b></p>
10037: <dl>
1.6 rillig 10038: <dt><span class="chapter"><a href="#infr.design">24. Design of the pkgsrc infrastructure</a></span></dt>
1.1 dsieger 10039: <dd><dl>
1.6 rillig 10040: <dt><span class="sect1"><a href="#infr.vardef">24.1. The meaning of variable definitions</a></span></dt>
10041: <dt><span class="sect1"><a href="#infr.vardef.problems">24.2. Avoiding problems before they arise</a></span></dt>
10042: <dt><span class="sect1"><a href="#infr.var">24.3. Variable evaluation</a></span></dt>
1.1 dsieger 10043: <dd><dl>
1.6 rillig 10044: <dt><span class="sect2"><a href="#infr.var.load">24.3.1. At load time</a></span></dt>
10045: <dt><span class="sect2"><a href="#infr.var.run">24.3.2. At runtime</a></span></dt>
1.1 dsieger 10046: </dl></dd>
1.6 rillig 10047: <dt><span class="sect1"><a href="#infr.varspec">24.4. How can variables be specified?</a></span></dt>
10048: <dt><span class="sect1"><a href="#infr.design.intf">24.5. Designing interfaces for Makefile fragments</a></span></dt>
1.1 dsieger 10049: <dd><dl>
1.6 rillig 10050: <dt><span class="sect2"><a href="#infr.design.intf.proc">24.5.1. Procedures with parameters</a></span></dt>
10051: <dt><span class="sect2"><a href="#infr.design.intf.action">24.5.2. Actions taken on behalf of parameters</a></span></dt>
1.1 dsieger 10052: </dl></dd>
1.6 rillig 10053: <dt><span class="sect1"><a href="#infr.order">24.6. The order in which files are loaded</a></span></dt>
1.1 dsieger 10054: <dd><dl>
1.6 rillig 10055: <dt><span class="sect2"><a href="#infr.order.prefs">24.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
10056: <dt><span class="sect2"><a href="#infr.order.pkg">24.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.1 dsieger 10057: </dl></dd>
10058: </dl></dd>
1.6 rillig 10059: <dt><span class="chapter"><a href="#regression">25. Regression tests</a></span></dt>
1.1 dsieger 10060: <dd><dl>
1.6 rillig 10061: <dt><span class="sect1"><a href="#regression.descr">25.1. The regression tests framework</a></span></dt>
10062: <dt><span class="sect1"><a href="#regression.run">25.2. Running the regression tests</a></span></dt>
10063: <dt><span class="sect1"><a href="#regression.new">25.3. Adding a new regression test</a></span></dt>
1.1 dsieger 10064: <dd><dl>
1.6 rillig 10065: <dt><span class="sect2"><a href="#regression.fun.override">25.3.1. Overridable functions</a></span></dt>
10066: <dt><span class="sect2"><a href="#regression.fun.helper">25.3.2. Helper functions</a></span></dt>
1.1 dsieger 10067: </dl></dd>
10068: </dl></dd>
1.6 rillig 10069: <dt><span class="chapter"><a href="#porting">26. Porting pkgsrc</a></span></dt>
1.1 dsieger 10070: <dd><dl>
1.6 rillig 10071: <dt><span class="sect1"><a href="#porting.opsys">26.1. Porting pkgsrc to a new operating system</a></span></dt>
10072: <dt><span class="sect1"><a href="#porting.compiler">26.2. Adding support for a new compiler</a></span></dt>
1.1 dsieger 10073: </dl></dd>
10074: </dl>
10075: </div>
10076: </div>
10077: <div class="chapter" lang="en">
10078: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 10079: <a name="infr.design"></a>Chapter 24. Design of the pkgsrc infrastructure</h2></div></div></div>
1.1 dsieger 10080: <div class="toc">
10081: <p><b>Table of Contents</b></p>
10082: <dl>
1.6 rillig 10083: <dt><span class="sect1"><a href="#infr.vardef">24.1. The meaning of variable definitions</a></span></dt>
10084: <dt><span class="sect1"><a href="#infr.vardef.problems">24.2. Avoiding problems before they arise</a></span></dt>
10085: <dt><span class="sect1"><a href="#infr.var">24.3. Variable evaluation</a></span></dt>
1.1 dsieger 10086: <dd><dl>
1.6 rillig 10087: <dt><span class="sect2"><a href="#infr.var.load">24.3.1. At load time</a></span></dt>
10088: <dt><span class="sect2"><a href="#infr.var.run">24.3.2. At runtime</a></span></dt>
1.1 dsieger 10089: </dl></dd>
1.6 rillig 10090: <dt><span class="sect1"><a href="#infr.varspec">24.4. How can variables be specified?</a></span></dt>
10091: <dt><span class="sect1"><a href="#infr.design.intf">24.5. Designing interfaces for Makefile fragments</a></span></dt>
1.1 dsieger 10092: <dd><dl>
1.6 rillig 10093: <dt><span class="sect2"><a href="#infr.design.intf.proc">24.5.1. Procedures with parameters</a></span></dt>
10094: <dt><span class="sect2"><a href="#infr.design.intf.action">24.5.2. Actions taken on behalf of parameters</a></span></dt>
1.1 dsieger 10095: </dl></dd>
1.6 rillig 10096: <dt><span class="sect1"><a href="#infr.order">24.6. The order in which files are loaded</a></span></dt>
1.1 dsieger 10097: <dd><dl>
1.6 rillig 10098: <dt><span class="sect2"><a href="#infr.order.prefs">24.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
10099: <dt><span class="sect2"><a href="#infr.order.pkg">24.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.1 dsieger 10100: </dl></dd>
10101: </dl>
10102: </div>
10103: <p>The pkgsrc infrastructure consists of many small Makefile
10104: fragments. Each such fragment needs a properly specified
10105: interface. This chapter explains how such an interface looks
10106: like.</p>
10107: <div class="sect1" lang="en">
10108: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 10109: <a name="infr.vardef"></a>24.1. The meaning of variable definitions</h2></div></div></div>
1.1 dsieger 10110: <p>Whenever a variable is defined in the pkgsrc
10111: infrastructure, the location and the way of definition provide
10112: much information about the intended use of that variable.
10113: Additionally, more documentation may be found in a header
10114: comment or in this pkgsrc guide.</p>
10115: <p>A special file is
10116: <code class="filename">mk/defaults/mk.conf</code>, which lists all
10117: variables that are intended to be user-defined. They are either
10118: defined using the <code class="literal">?=</code> operator or they are
10119: left undefined because defining them to anything would
10120: effectively mean “<span class="quote">yes</span>”. All these variables may be
10121: overridden by the pkgsrc user in the <code class="varname">MAKECONF</code>
10122: file.</p>
10123: <p>Outside this file, the following conventions apply:
10124: Variables that are defined using the <code class="literal">?=</code>
10125: operator may be overridden by a package.</p>
10126: <p>Variables that are defined using the <code class="literal">=</code>
10127: operator may be used read-only at run-time.</p>
10128: <p>Variables whose name starts with an underscore must not be
10129: accessed outside the pkgsrc infrastructure at all. They may
10130: change without further notice.</p>
10131: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
10132: <h3 class="title">Note</h3>
10133: <p>These conventions are currently not applied
10134: consistently to the complete pkgsrc
10135: infrastructure.</p>
10136: </div>
10137: </div>
10138: <div class="sect1" lang="en">
10139: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 10140: <a name="infr.vardef.problems"></a>24.2. Avoiding problems before they arise</h2></div></div></div>
1.1 dsieger 10141: <p>All variables that contain lists of things should default
10142: to being empty. Two examples that do not follow this rule are
10143: <code class="varname">USE_LANGUAGES</code> and
10144: <code class="varname">DISTFILES</code>. These variables cannot simply be
10145: modified using the <code class="literal">+=</code> operator in package
10146: <code class="filename">Makefile</code>s (or other files included by
10147: them), since there is no guarantee whether the variable is
10148: already set or not, and what its value is. In the case of
10149: <code class="varname">DISTFILES</code>, the packages “<span class="quote">know</span>”
10150: the default value and just define it as in the following
10151: example.</p>
10152: <pre class="programlisting">
10153: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
10154: </pre>
10155: <p>Because of the selection of this default value, the same
10156: value appears in many package Makefiles. Similarly for
10157: <code class="varname">USE_LANGUAGES</code>, but in this case the default
10158: value (“<span class="quote"><code class="literal">c</code></span>”) is so short that it
10159: doesn't stand out. Nevertheless it is mentioned in many
10160: files.</p>
10161: </div>
10162: <div class="sect1" lang="en">
10163: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 10164: <a name="infr.var"></a>24.3. Variable evaluation</h2></div></div></div>
1.1 dsieger 10165: <div class="sect2" lang="en">
10166: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 10167: <a name="infr.var.load"></a>24.3.1. At load time</h3></div></div></div>
1.1 dsieger 10168: <p>Variable evaluation takes place either at load time or at
10169: runtime, depending on the context in which they occur. The
10170: contexts where variables are evaluated at load time are:</p>
10171: <div class="itemizedlist"><ul type="disc">
10172: <li><p>The right hand side of the <code class="literal">:=</code>
10173: and <code class="literal">!=</code> operators,</p></li>
10174: <li><p>Make directives like <code class="literal">.if</code> or
10175: <code class="literal">.for</code>,</p></li>
10176: <li><p>Dependency lines.</p></li>
10177: </ul></div>
10178: <p>A special exception are references to the iteration
10179: variables of <code class="literal">.for</code> loops, which are expanded
10180: inline, no matter in which context they appear.</p>
10181: <p>As the values of variables may change during load time,
10182: care must be taken not to evaluate them by accident. Typical
10183: examples for variables that should not be evaluated at load time
10184: are <code class="varname">DEPENDS</code> and
10185: <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
10186: clear, here is an example:</p>
10187: <pre class="programlisting">
10188: CONFIGURE_ARGS= # none
10189: CFLAGS= -O
10190: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
10191:
10192: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
10193:
10194: CFLAGS+= -Wall
10195: </pre>
10196: <p>This code shows how the use of the <code class="literal">:=</code>
10197: operator can quickly lead to unexpected results. The first
10198: paragraph is fairly common code. The second paragraph evaluates
10199: the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
10200: <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
10201: <code class="literal">-Wall</code> is appended to the
10202: <code class="varname">CFLAGS</code>, but this addition will not appear in
10203: <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
10204: paragraphs from above typically occur in completely unrelated
10205: files.</p>
10206: </div>
10207: <div class="sect2" lang="en">
10208: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 10209: <a name="infr.var.run"></a>24.3.2. At runtime</h3></div></div></div>
1.1 dsieger 10210: <p>After all the files have been loaded, the values of the
10211: variables cannot be changed anymore. Variables that are used in
10212: the shell commands are expanded at this point.</p>
10213: </div>
10214: </div>
10215: <div class="sect1" lang="en">
10216: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 10217: <a name="infr.varspec"></a>24.4. How can variables be specified?</h2></div></div></div>
1.1 dsieger 10218: <p>There are many ways in which the definition and use of a
10219: variable can be restricted in order to detect bugs and
10220: violations of the (mostly unwritten) policies. See the
10221: <code class="literal">pkglint</code> developer's documentation for further
10222: details.</p>
10223: </div>
10224: <div class="sect1" lang="en">
10225: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 10226: <a name="infr.design.intf"></a>24.5. Designing interfaces for Makefile fragments</h2></div></div></div>
1.1 dsieger 10227: <p>Most of the <code class="filename">.mk</code> files fall into one
10228: of the following classes. Cases where a file falls into more
10229: than one class should be avoided as it often leads to subtle
10230: bugs.</p>
10231: <div class="sect2" lang="en">
10232: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 10233: <a name="infr.design.intf.proc"></a>24.5.1. Procedures with parameters</h3></div></div></div>
1.1 dsieger 10234: <p>In a traditional imperative programming language some of
10235: the <code class="filename">.mk</code> files could be described as
1.14 ! jmcneill 10236: procedures. They take some input parameters and—after
! 10237: inclusion—provide a result in output parameters. Since all
1.1 dsieger 10238: variables in <code class="filename">Makefile</code>s have global scope
10239: care must be taken not to use parameter names that have already
10240: another meaning. For example, <code class="varname">PKGNAME</code> is a
10241: bad choice for a parameter name.</p>
10242: <p>Procedures are completely evaluated at preprocessing time.
10243: That is, when calling a procedure all input parameters must be
10244: completely resolvable. For example,
10245: <code class="varname">CONFIGURE_ARGS</code> should never be an input
10246: parameter since it is very likely that further text will be
10247: added after calling the procedure, which would effectively apply
10248: the procedure to only a part of the variable. Also, references
10249: to other variables wit will be modified after calling the
10250: procedure.</p>
10251: <p>A procedure can declare its output parameters either as
10252: suitable for use in preprocessing directives or as only
10253: available at runtime. The latter alternative is for variables
10254: that contain references to other runtime variables.</p>
10255: <p>Procedures shall be written such that it is possible to
10256: call the procedure more than once. That is, the file must not
10257: contain multiple-inclusion guards.</p>
10258: <p>Examples for procedures are
10259: <code class="filename">mk/bsd.options.mk</code> and
10260: <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
10261: that the parameters are evaluated at load time, they should be
10262: assigned using the <code class="literal">:=</code> operator, which should
10263: be used only for this purpose.</p>
10264: </div>
10265: <div class="sect2" lang="en">
10266: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 10267: <a name="infr.design.intf.action"></a>24.5.2. Actions taken on behalf of parameters</h3></div></div></div>
1.1 dsieger 10268: <p>Action files take some input parameters and may define
10269: runtime variables. They shall not define loadtime variables.
10270: There are action files that are included implicitly by the
10271: pkgsrc infrastructure, while other must be included
10272: explicitly.</p>
10273: <p>An example for action files is
10274: <code class="filename">mk/subst.mk</code>.</p>
10275: </div>
10276: </div>
10277: <div class="sect1" lang="en">
10278: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 10279: <a name="infr.order"></a>24.6. The order in which files are loaded</h2></div></div></div>
1.1 dsieger 10280: <p>Package <code class="filename">Makefile</code>s usually consist of
10281: a set of variable definitions, and include the file
10282: <code class="filename">../../mk/bsd.pkg.mk</code> in the very last line.
10283: Before that, they may also include various other
10284: <code class="filename">*.mk</code> files if they need to query the
10285: availability of certain features like the type of compiler or
10286: the X11 implementation. Due to the heavy use of preprocessor
10287: directives like <code class="literal">.if</code> and
10288: <code class="literal">.for</code>, the order in which the files are loaded
10289: matters.</p>
10290: <p>This section describes at which point the various files
10291: are loaded and gives reasons for that order.</p>
10292: <div class="sect2" lang="en">
10293: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 10294: <a name="infr.order.prefs"></a>24.6.1. The order in <code class="filename">bsd.prefs.mk</code>
1.1 dsieger 10295: </h3></div></div></div>
10296: <p>The very first action in <code class="filename">bsd.prefs.mk</code>
10297: is to define some essential variables like
10298: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code> and
10299: <code class="varname">MACHINE_ARCH</code>.</p>
10300: <p>Then, the user settings are loaded from the file specified
1.10 hubertf 10301: in <code class="varname">MAKECONF</code>, which is usually <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>.
1.4 rillig 10302: After that, those variables
1.1 dsieger 10303: that have not been overridden by the user are loaded from
10304: <code class="filename">mk/defaults/mk.conf</code>.</p>
10305: <p>After the user settings, the system settings and platform
10306: settings are loaded, which may override the user
10307: settings.</p>
10308: <p>Then, the tool definitions are loaded. The tool wrappers
10309: are not yet in effect. This only happens when building a
10310: package, so the proper variables must be used instead of the
10311: direct tool names.</p>
10312: <p>As the last steps, some essential variables from the
10313: wrapper and the package system flavor are loaded, as well as the
10314: variables that have been cached in earlier phases of a package
10315: build.</p>
10316: </div>
10317: <div class="sect2" lang="en">
10318: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 10319: <a name="infr.order.pkg"></a>24.6.2. The order in <code class="filename">bsd.pkg.mk</code>
1.1 dsieger 10320: </h3></div></div></div>
10321: <p>First, <code class="filename">bsd.prefs.mk</code> is loaded.</p>
10322: <p>Then, the various <code class="filename">*-vars.mk</code> files are
10323: loaded, which fill default values for those variables that have
10324: not been defined by the package. These variables may later
10325: be used even in unrelated files.</p>
10326: <p>Then, the file <code class="filename">bsd.pkg.error.mk</code>
10327: provides the target <code class="literal">error-check</code> that is added
10328: as a special dependency to all other targets that use
10329: <code class="varname">DELAYED_ERROR_MSG</code> or
10330: <code class="varname">DELAYED_WARNING_MSG</code>.</p>
10331: <p>Then, the package-specific hacks from
10332: <code class="filename">hacks.mk</code> are included.</p>
10333: <p>Then, various other files follow. Most of them don't have
10334: any dependencies on what they need to have included before or
10335: after them, though some do.</p>
10336: <p>The code to check <code class="varname">PKG_FAIL_REASON</code> and
10337: <code class="varname">PKG_SKIP_REASON</code> is then executed, which
10338: restricts the use of these variables to all the files that have
10339: been included before. Appearances in later files will be
10340: silently ignored.</p>
10341: <p>Then, the files for the main targets are included, in the
10342: order of later execution, though the actual order should not
10343: matter.</p>
10344: <p>At last, some more files are included that don't set any
10345: interesting variables but rather just define make targets to be
10346: executed.</p>
10347: </div>
10348: </div>
10349: </div>
10350: <div class="chapter" lang="en">
10351: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 10352: <a name="regression"></a>Chapter 25. Regression tests</h2></div></div></div>
1.1 dsieger 10353: <div class="toc">
10354: <p><b>Table of Contents</b></p>
10355: <dl>
1.6 rillig 10356: <dt><span class="sect1"><a href="#regression.descr">25.1. The regression tests framework</a></span></dt>
10357: <dt><span class="sect1"><a href="#regression.run">25.2. Running the regression tests</a></span></dt>
10358: <dt><span class="sect1"><a href="#regression.new">25.3. Adding a new regression test</a></span></dt>
1.1 dsieger 10359: <dd><dl>
1.6 rillig 10360: <dt><span class="sect2"><a href="#regression.fun.override">25.3.1. Overridable functions</a></span></dt>
10361: <dt><span class="sect2"><a href="#regression.fun.helper">25.3.2. Helper functions</a></span></dt>
1.1 dsieger 10362: </dl></dd>
10363: </dl>
10364: </div>
10365: <p>The pkgsrc infrastructure consists of a large codebase,
10366: and there are many corners where every little bit of a file is
10367: well thought out, making pkgsrc likely to fail as soon as
10368: anything is changed near those parts. To prevent most changes
10369: from breaking anything, a suite of regression tests should go
10370: along with every important part of the pkgsrc infrastructure.
10371: This chapter describes how regression tests work in pkgsrc and
10372: how you can add new tests.</p>
10373: <div class="sect1" lang="en">
10374: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 10375: <a name="regression.descr"></a>25.1. The regression tests framework</h2></div></div></div>
1.1 dsieger 10376: <p></p>
10377: </div>
10378: <div class="sect1" lang="en">
10379: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 10380: <a name="regression.run"></a>25.2. Running the regression tests</h2></div></div></div>
1.1 dsieger 10381: <p>You first need to install the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkg_regress/README.html" target="_top"><code class="filename">pkgtools/pkg_regress</code></a> package, which
1.10 hubertf 10382: provides the <span class="command"><strong>pkg_regress</strong></span> command. Then you
1.1 dsieger 10383: can simply run that command, which will run all tests in the
10384: <code class="filename">regress</code> category.</p>
10385: </div>
10386: <div class="sect1" lang="en">
10387: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 10388: <a name="regression.new"></a>25.3. Adding a new regression test</h2></div></div></div>
1.1 dsieger 10389: <p>Every directory in the <code class="filename">regress</code>
10390: category that contains a file called <code class="filename">spec</code>
10391: is considered a regression test. This file is a shell program
1.10 hubertf 10392: that is included by the <span class="command"><strong>pkg_regress</strong></span> command.
1.1 dsieger 10393: The following functions can be overridden to suit your
10394: needs.</p>
10395: <div class="sect2" lang="en">
10396: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 10397: <a name="regression.fun.override"></a>25.3.1. Overridable functions</h3></div></div></div>
1.1 dsieger 10398: <p>These functions do not take any parameters. They are all
10399: called in “<span class="quote">set -e</span>” mode, so you should be careful
10400: to check the exitcodes of any commands you run in the
10401: test.</p>
10402: <div class="variablelist"><dl>
10403: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
10404: <dd><p>This function prepares the environment for the
10405: test. By default it does nothing.</p></dd>
10406: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
10407: <dd><p>This function runs the actual test. By default,
10408: it calls <code class="varname">TEST_MAKE</code> with the arguments
10409: <code class="varname">MAKEARGS_TEST</code> and writes its output including
10410: error messages into the file
10411: <code class="varname">TEST_OUTFILE</code>.</p></dd>
10412: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
10413: <dd><p>This function is run after the test and is
10414: typically used to compare the actual output from the one that is
10415: expected. It can make use of the various helper functions from
10416: the next section.</p></dd>
10417: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
10418: <dd><p>This function cleans everything up after the
10419: test has been run. By default it does nothing.</p></dd>
10420: </dl></div>
10421: </div>
10422: <div class="sect2" lang="en">
10423: <div class="titlepage"><div><div><h3 class="title">
1.6 rillig 10424: <a name="regression.fun.helper"></a>25.3.2. Helper functions</h3></div></div></div>
1.1 dsieger 10425: <div class="variablelist"><dl>
10426: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
10427: <dd><p>This function compares the exitcode of the
1.10 hubertf 10428: <span class="command"><strong>do_test()</strong></span> function with its first parameter.
1.1 dsieger 10429: If they differ, the test will fail.</p></dd>
10430: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
10431: <dd><p>This function checks for each of its parameters
1.10 hubertf 10432: if the output from <span class="command"><strong>do_test()</strong></span> matches the
1.1 dsieger 10433: extended regular expression. If it does not, the test will
10434: fail.</p></dd>
10435: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
10436: <dd><p>This function checks for each of its parameters
1.10 hubertf 10437: if the output from <span class="command"><strong>do_test()</strong></span> does
1.1 dsieger 10438: <span class="emphasis"><em>not</em></span> match the extended regular expression.
10439: If any of the regular expressions matches, the test will
10440: fail.</p></dd>
10441: </dl></div>
10442: </div>
10443: </div>
10444: </div>
10445: <div class="chapter" lang="en">
10446: <div class="titlepage"><div><div><h2 class="title">
1.6 rillig 10447: <a name="porting"></a>Chapter 26. Porting pkgsrc</h2></div></div></div>
1.1 dsieger 10448: <div class="toc">
10449: <p><b>Table of Contents</b></p>
10450: <dl>
1.6 rillig 10451: <dt><span class="sect1"><a href="#porting.opsys">26.1. Porting pkgsrc to a new operating system</a></span></dt>
10452: <dt><span class="sect1"><a href="#porting.compiler">26.2. Adding support for a new compiler</a></span></dt>
1.1 dsieger 10453: </dl>
10454: </div>
10455: <p>The pkgsrc system has already been ported to many
10456: operating systems, hardware architectures and compilers. This
10457: chapter explains the necessary steps to make pkgsrc even more
10458: portable.</p>
10459: <div class="sect1" lang="en">
10460: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 10461: <a name="porting.opsys"></a>26.1. Porting pkgsrc to a new operating system</h2></div></div></div>
1.1 dsieger 10462: <p>To port pkgsrc to a new operating system (called
10463: <code class="literal">MyOS</code> in this example), you need to touch the
10464: following files:</p>
10465: <div class="variablelist"><dl>
10466: <dt><span class="term"><code class="filename">pkgtools/bootstrap-mk-files/files/mods/<em class="replaceable"><code>MyOS</code></em>.sys.mk</code></span></dt>
10467: <dd><p>This file contains some basic definitions, for
10468: example the name of the C
10469: compiler.</p></dd>
10470: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
10471: <dd><p>Insert code that defines the variables
10472: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
10473: <code class="varname">LOWER_OS_VERSION</code>,
10474: <code class="varname">LOWER_VENDOR</code>,
10475: <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
10476: <code class="varname">APPEND_ELF</code>, and the other variables that
10477: appear in this file.</p></dd>
10478: <dt><span class="term"><code class="filename">mk/platform/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
10479: <dd><p>This file contains the platform-specific
10480: definitions that are used by pkgsrc. Start by copying one of the
10481: other files and edit it to your
10482: needs.</p></dd>
10483: <dt><span class="term"><code class="filename">mk/platform/<em class="replaceable"><code>MyOS</code></em>.pkg.dist</code></span></dt>
10484: <dd><p>This file contains a list of directories,
10485: together with their permission bits and ownership. These
10486: directories will be created automatically with every package
10487: that explicitly sets <code class="varname">USE_MTREE</code>. This feature will
10488: be removed.</p></dd>
10489: <dt><span class="term"><code class="filename">mk/platform/<em class="replaceable"><code>MyOS</code></em>.x11.dist</code></span></dt>
10490: <dd><p>Just copy one of the pre-existing x11.dist files
10491: to your
10492: <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
10493: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
10494: <dd><p>On some operating systems, the tools that are
10495: provided with the base system are not good enough for pkgsrc.
1.10 hubertf 10496: For example, there are many versions of <a class="citerefentry" 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
1.1 dsieger 10497: narrow limit on the line length they can process. Therefore
10498: pkgsrc brings its own tools, which can be enabled
10499: here.</p></dd>
10500: <dt><span class="term"><code class="filename">mk/tools/tools.<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
10501: <dd><p>This file defines the paths to all the tools
10502: that are needed by one or the other package in pkgsrc, as well
10503: as by pkgsrc itself. Find out where these tools are on your
10504: platform and add them.</p></dd>
10505: </dl></div>
10506: <p>Now, you should be able to build some basic packages, like
10507: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/lang/perl5/README.html" target="_top"><code class="filename">lang/perl5</code></a>, <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/shells/bash/README.html" target="_top"><code class="filename">shells/bash</code></a>.</p>
10508: </div>
10509: <div class="sect1" lang="en">
10510: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.6 rillig 10511: <a name="porting.compiler"></a>26.2. Adding support for a new compiler</h2></div></div></div>
1.1 dsieger 10512: <p>TODO</p>
10513: </div>
10514: </div>
10515: </div>
10516: <div class="appendix" lang="en">
10517: <div class="titlepage"><div><div><h2 class="title">
10518: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
10519: <div class="toc">
10520: <p><b>Table of Contents</b></p>
10521: <dl>
10522: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
10523: <dd><dl>
10524: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
10525: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
10526: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
1.10 hubertf 10527: <dt><span class="sect2"><a href="#checking-package-with-pkglint">A.1.4. Checking a package with <span class="command"><strong>pkglint</strong></span></a></span></dt>
1.1 dsieger 10528: </dl></dd>
10529: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
10530: </dl>
10531: </div>
10532: <p>We checked to find a piece of software that wasn't in the packages
10533: collection, and picked GNU bison. Quite why someone would want to have
1.10 hubertf 10534: <span class="command"><strong>bison</strong></span> when Berkeley <span class="command"><strong>yacc</strong></span> is already
1.1 dsieger 10535: present in the tree is beyond us, but it's useful for the purposes of
10536: this exercise.</p>
10537: <div class="sect1" lang="en">
10538: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10539: <a name="example-files"></a>A.1. files</h2></div></div></div>
10540: <div class="sect2" lang="en">
10541: <div class="titlepage"><div><div><h3 class="title">
10542: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
10543: <pre class="programlisting">
10544: # $NetBSD$
10545: #
10546:
10547: DISTNAME= bison-1.25
10548: CATEGORIES= devel
10549: MASTER_SITES= ${MASTER_SITE_GNU}
10550:
10551: MAINTAINER= thorpej@NetBSD.org
10552: HOMEPAGE= http://www.gnu.org/software/bison/bison.html
10553: COMMENT= GNU yacc clone
10554:
10555: GNU_CONFIGURE= yes
10556: INFO_FILES= bison.info
10557:
10558: .include "../../mk/bsd.pkg.mk"
10559: </pre>
10560: </div>
10561: <div class="sect2" lang="en">
10562: <div class="titlepage"><div><div><h3 class="title">
10563: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
10564: <pre class="programlisting">
10565: GNU version of yacc. Can make re-entrant parsers, and numerous other
1.10 hubertf 10566: improvements. Why you would want this when Berkeley <a class="citerefentry" 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.1 dsieger 10567: of the NetBSD source tree is beyond me.
10568: </pre>
10569: </div>
10570: <div class="sect2" lang="en">
10571: <div class="titlepage"><div><div><h3 class="title">
10572: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
10573: <pre class="programlisting">
10574: @comment $NetBSD$
10575: bin/bison
10576: man/man1/bison.1.gz
10577: share/bison.simple
10578: share/bison.hairy
10579: </pre>
10580: </div>
10581: <div class="sect2" lang="en">
10582: <div class="titlepage"><div><div><h3 class="title">
1.10 hubertf 10583: <a name="checking-package-with-pkglint"></a>A.1.4. Checking a package with <span class="command"><strong>pkglint</strong></span>
1.1 dsieger 10584: </h3></div></div></div>
10585: <p>The NetBSD package system comes with
10586: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>
10587: which helps to check the contents of these
10588: files. After installation it is quite easy to use, just change to the
10589: directory of the package you wish to examine and execute
1.10 hubertf 10590: <span class="command"><strong>pkglint</strong></span>:</p>
1.1 dsieger 10591: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
10592: looks fine.</pre>
10593: <p>Depending on the supplied command line arguments (see pkglint(1)),
1.10 hubertf 10594: more checks will be performed. Use e.g. <span class="command"><strong>pkglint -Call
1.1 dsieger 10595: -Wall</strong></span> for a very thorough check.</p>
10596: </div>
10597: </div>
10598: <div class="sect1" lang="en">
10599: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10600: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
10601: <p>Create the directory where the package lives,
10602: plus any auxiliary directories:</p>
10603: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
10604: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
10605: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
10606: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
10607: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.10 hubertf 10608: <code class="filename">PLIST</code> (see <a class="xref" href="#components" title="Chapter 11. Package components - files, directories and contents">Chapter 11, <i>Package components - files, directories and contents</i></a>)
1.1 dsieger 10609: then continue with fetching the distfile:</p>
10610: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
10611: >> bison-1.25.tar.gz doesn't seem to exist on this system.
10612: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
10613: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
10614: ftp: Error retrieving file: 500 Internal error
10615:
10616: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
10617: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
10618: ftp: Error retrieving file: 500 Internal error
10619:
10620: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
10621: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
10622: Successfully retrieved file.</pre>
10623: <p>Generate the checksum of the distfile into
10624: <code class="filename">distinfo</code>:</p>
10625: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makedistinfo</code></strong></pre>
10626: <p>Now compile:</p>
10627: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
10628: >> Checksum OK for bison-1.25.tar.gz.
10629: ===> Extracting for bison-1.25
10630: ===> Patching for bison-1.25
10631: ===> Ignoring empty patch directory
10632: ===> Configuring for bison-1.25
10633: creating cache ./config.cache
10634: checking for gcc... cc
10635: checking whether we are using GNU C... yes
10636: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
10637: checking how to run the C preprocessor... cc -E
10638: checking for minix/config.h... no
10639: checking for POSIXized ISC... no
10640: checking whether cross-compiling... no
10641: checking for ANSI C header files... yes
10642: checking for string.h... yes
10643: checking for stdlib.h... yes
10644: checking for memory.h... yes
10645: checking for working const... yes
10646: checking for working alloca.h... no
10647: checking for alloca... yes
10648: checking for strerror... yes
10649: updating cache ./config.cache
10650: creating ./config.status
10651: creating Makefile
10652: ===> Building for bison-1.25
10653: 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
10654: 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
10655: 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
10656: 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
10657: 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
10658: 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
10659: 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
10660: 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
10661: 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
10662: 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
10663: 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
10664: 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
10665: 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
10666: 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
10667: 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
10668: 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
10669: 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
10670: 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
10671: 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
10672: 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
10673: 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
10674: 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
10675: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
10676: rm -f bison.s1
10677: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1</pre>
10678: <p>Everything seems OK, so install the files:</p>
10679: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
10680: >> Checksum OK for bison-1.25.tar.gz.
10681: ===> Installing for bison-1.25
10682: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
10683: rm -f /usr/pkg/bin/bison
10684: cd /usr/pkg/share; rm -f bison.simple bison.hairy
10685: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
10686: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
10687: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
10688: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
10689: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
10690: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
10691: ===> Registering installation for bison-1.25</pre>
10692: <p>You can now use bison, and also - if you decide so - remove it with
1.10 hubertf 10693: <span class="command"><strong>pkg_delete bison</strong></span>. Should you decide that you want a
1.1 dsieger 10694: binary package, do this now:</p>
10695: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
10696: >> Checksum OK for bison-1.25.tar.gz.
10697: ===> Building package for bison-1.25
10698: Creating package bison-1.25.tgz
10699: Registering depends:.
10700: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
10701: <p>Now that you don't need the source and object files
10702: any more, clean up:</p>
10703: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
10704: ===> Cleaning for bison-1.25</pre>
10705: </div>
10706: </div>
10707: <div class="appendix" lang="en">
10708: <div class="titlepage"><div><div><h2 class="title">
10709: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
10710: <div class="toc">
10711: <p><b>Table of Contents</b></p>
10712: <dl>
10713: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
10714: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
10715: </dl>
10716: </div>
10717: <div class="sect1" lang="en">
10718: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10719: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
10720: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
10721: ===> Checking for vulnerabilities in figlet-2.2.1nb2
10722: => figlet221.tar.gz doesn't seem to exist on this system.
10723: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
10724: => [172219 bytes]
10725: Connected to ftp.plig.net.
10726: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
10727: 331 Guest login ok, send your complete e-mail address as password.
10728: 230-You are user #5 of 500 simultaneous users allowed.
10729: 230-
10730: 230- ___ _ _ _
10731: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
10732: 230- | _| _| . |_| . | | | . |_| . | _| . |
10733: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
10734: 230- |_| |_| |___| |___|
10735: 230-
10736: 230-** Welcome to ftp.plig.org **
10737: 230-
10738: 230-Please note that all transfers from this FTP site are logged. If you
10739: 230-do not like this, please disconnect now.
10740: 230-
10741: 230-This arhive is available via
10742: 230-
10743: 230-HTTP: http://ftp.plig.org/
10744: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
10745: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
10746: 230-
10747: 230-Please email comments, bug reports and requests for packages to be
10748: 230-mirrored to ftp-admin@plig.org.
10749: 230-
10750: 230-
10751: 230 Logged in anonymously.
10752: Remote system type is UNIX.
10753: Using binary mode to transfer files.
10754: 200 Type okay.
10755: 250 "/pub" is new cwd.
10756: 250-"/pub/figlet" is new cwd.
10757: 250-
10758: 250-Welcome to the figlet archive at ftp.figlet.org
10759: 250-
10760: 250- ftp://ftp.figlet.org/pub/figlet/
10761: 250-
10762: 250-The official FIGlet web page is:
10763: 250- http://www.figlet.org/
10764: 250-
10765: 250-If you have questions, please mailto:info@figlet.org. If you want to
10766: 250-contribute a font or something else, you can email us.
10767: 250
10768: 250 "/pub/figlet/program" is new cwd.
10769: 250 "/pub/figlet/program/unix" is new cwd.
10770: local: figlet221.tar.gz remote: figlet221.tar.gz
10771: 502 Unimplemented command.
10772: 227 Entering Passive Mode (195,40,6,41,246,104)
10773: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
10774: 38% |************** | 65800 64.16 KB/s 00:01 ETA
10775: 226 Transfer completed.
10776: 172219 bytes received in 00:02 (75.99 KB/s)
10777: 221 Goodbye.
10778: => Checksum OK for figlet221.tar.gz.
10779: ===> Extracting for figlet-2.2.1nb2
10780: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
10781: ===> Patching for figlet-2.2.1nb2
10782: ===> Applying pkgsrc patches for figlet-2.2.1nb2
10783: ===> Overriding tools for figlet-2.2.1nb2
10784: ===> Creating toolchain wrappers for figlet-2.2.1nb2
10785: ===> Configuring for figlet-2.2.1nb2
10786: ===> Building for figlet-2.2.1nb2
10787: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
10788: chmod a+x figlet
10789: gcc -O2 -o chkfont chkfont.c
10790: => Unwrapping files-to-be-installed.
10791: <code class="prompt">#</code>
10792: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
10793: ===> Checking for vulnerabilities in figlet-2.2.1nb2
10794: ===> Installing for figlet-2.2.1nb2
10795: install -d -o root -g wheel -m 755 /usr/pkg/bin
10796: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
10797: mkdir -p /usr/pkg/share/figlet
10798: cp figlet /usr/pkg/bin
10799: cp chkfont /usr/pkg/bin
10800: chmod 555 figlist showfigfonts
10801: cp figlist /usr/pkg/bin
10802: cp showfigfonts /usr/pkg/bin
10803: cp fonts/*.flf /usr/pkg/share/figlet
10804: cp fonts/*.flc /usr/pkg/share/figlet
10805: cp figlet.6 /usr/pkg/man/man6
10806: ===> Registering installation for figlet-2.2.1nb2
10807: <code class="prompt">#</code></pre>
10808: </div>
10809: <div class="sect1" lang="en">
10810: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10811: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
10812: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
10813: ===> Checking for vulnerabilities in figlet-2.2.1nb2
10814: ===> Packaging figlet-2.2.1nb2
10815: ===> Building binary package for figlet-2.2.1nb2
10816: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
10817: Using SrcDir value of /usr/pkg
10818: Registering depends:.
10819: <code class="prompt">#</code></pre>
10820: </div>
10821: </div>
10822: <div class="appendix" lang="en">
10823: <div class="titlepage"><div><div><h2 class="title">
10824: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
10825: <div class="toc">
10826: <p><b>Table of Contents</b></p>
10827: <dl>
10828: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
10829: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
10830: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
10831: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
1.3 rillig 10832: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages</code>: Binary packages</a></span></dt>
1.8 rillig 10833: <dt><span class="sect1"><a href="#ftp-reports">C.6. <code class="filename">reports</code>: Bulk build reports</a></span></dt>
10834: <dt><span class="sect1"><a href="#ftp-source">C.7. <code class="filename">current</code>,
1.1 dsieger 10835: <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
10836: source packages</a></span></dt>
10837: </dl>
10838: </div>
10839: <p>As in other big projects, the directory layout of pkgsrc
10840: is quite complex for newbies. This chapter explains where you
10841: find things on the FTP server. The base directory on
1.10 hubertf 10842: <code class="filename">ftp.NetBSD.org</code> is <a class="ulink" href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top"><code class="filename">/pub/pkgsrc/</code></a>.
1.1 dsieger 10843: On other servers it may be different, but inside this directory,
10844: everything should look the same, no matter on which server you
10845: are. This directory contains some subdirectories, which are
10846: explained below.</p>
10847: <div class="sect1" lang="en">
10848: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10849: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
1.9 rillig 10850: <p>This directory used to contain binary packages of the
10851: package management tools for various platforms. For those
10852: package collections that need them, they are now stored near the
1.10 hubertf 10853: binary packages, so you should look <a class="link" href="#ftp-packages" title="C.5. packages: Binary packages">in the <code class="filename">packages</code>
1.9 rillig 10854: directory</a>.</p>
1.1 dsieger 10855: </div>
10856: <div class="sect1" lang="en">
10857: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10858: <a name="ftp-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
10859: <p>The directory <code class="filename">distfiles</code> contains lots
10860: of archive files from all pkgsrc packages, which are mirrored
10861: here. The subdirectories are called after their package names
10862: and are used when the distributed files have names that don't
10863: explicitly contain a version number or are otherwise too generic
10864: (for example <code class="filename">release.tar.gz</code>).</p>
10865: </div>
10866: <div class="sect1" lang="en">
10867: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10868: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
10869: <p>This directory is currently not in use.</p>
10870: </div>
10871: <div class="sect1" lang="en">
10872: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10873: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
10874: <p>This directory contains things that individual pkgsrc
10875: developers find worth publishing.</p>
10876: </div>
10877: <div class="sect1" lang="en">
10878: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.3 rillig 10879: <a name="ftp-packages"></a>C.5. <code class="filename">packages</code>: Binary packages</h2></div></div></div>
10880: <p>This directory contains binary packages for the various
10881: platforms that are supported by pkgsrc.
10882: Each subdirectory is of the form <em class="replaceable"><code>OPSYS</code></em>/<em class="replaceable"><code>ARCH</code></em>/<em class="replaceable"><code>OSVERSION_TAG</code></em>. The meaning of these variables is:</p>
10883: <div class="itemizedlist"><ul type="disc">
1.8 rillig 10884: <li><p><code class="varname">OPSYS</code> is the name of the
1.9 rillig 10885: operating system for which the packages have been built. The
1.10 hubertf 10886: name is taken from the output of the <span class="command"><strong>uname</strong></span>
1.9 rillig 10887: command, so it may differ from the one you are used to
10888: hear.</p></li>
1.8 rillig 10889: <li><p><code class="varname">ARCH</code> is the hardware
10890: architecture of the platform for which the packages have been
1.10 hubertf 10891: built. It also includes the <code class="varname">ABI</code> (Application
10892: Binary Interface) for platforms that have several of
10893: them.</p></li>
1.8 rillig 10894: <li><p><code class="varname">OSVERSION</code> is the version of
10895: the operating system. For version numbers that change often (for
10896: example NetBSD-current), the often-changing part should be
10897: replaced with an <code class="literal">x</code>, for example
10898: <code class="literal">4.99.x</code>.</p></li>
10899: <li><p><code class="varname">TAG</code> is either
10900: <code class="literal">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>
10901: for a stable branch, or <code class="literal">head</code> for packages
10902: built from the HEAD branch. The latter should only be used when
10903: the packages are updated on a regular basis. Otherwise the date
10904: from checking out pkgsrc should be appended, for example
10905: <code class="literal">head_20071015</code>.</p></li>
1.3 rillig 10906: </ul></div>
10907: <p>The rationale for exactly this scheme is that the pkgsrc users looking for binary packages
10908: can quickly click through the directories on the
10909: server and find the best binary packages for their machines. Since they
10910: usually know the operating system and the hardware architecture, OPSYS
10911: and ARCH are placed first. After these choices, they can select the
10912: best combination of OSVERSION and TAG together, since it is usually the
10913: case that packages stay compatible between different version of the
10914: operating system.</p>
10915: <p>In each of these directories, there is a
10916: whole binary packages collection for a specific platform. It has a directory called
1.1 dsieger 10917: <code class="filename">All</code> which contains all binary packages.
10918: Besides that, there are various category directories that
10919: contain symbolic links to the real binary packages.</p>
10920: </div>
10921: <div class="sect1" lang="en">
10922: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.8 rillig 10923: <a name="ftp-reports"></a>C.6. <code class="filename">reports</code>: Bulk build reports</h2></div></div></div>
10924: <p>Here are the reports from bulk builds, for those who want
10925: to fix packages that didn't build on some of the platforms. The
1.10 hubertf 10926: structure of subdirectories should look like the one in <a class="xref" href="#ftp-packages" title="C.5. packages: Binary packages">Section C.5, “<code class="filename">packages</code>: Binary packages”</a>.</p>
1.8 rillig 10927: </div>
10928: <div class="sect1" lang="en">
10929: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10930: <a name="ftp-source"></a>C.7. <code class="filename">current</code>,
1.1 dsieger 10931: <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
10932: source packages</h2></div></div></div>
10933: <p>These directories contain the “<span class="quote">real</span>” pkgsrc,
10934: that is the files that define how to create binary packages from
10935: source archives.</p>
10936: <p>The directory <code class="filename">pkgsrc</code> contains a
10937: snapshot of the CVS repository, which is updated regularly. The
10938: file <code class="filename">pkgsrc.tar.gz</code> contains the same as the
10939: directory, ready to be downloaded as a whole.</p>
10940: <p>In the directories for the quarterly branches, there is an
10941: additional file called
10942: <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
10943: which contains the state of pkgsrc when it was branched.</p>
10944: </div>
10945: </div>
10946: <div class="appendix" lang="en">
10947: <div class="titlepage"><div><div><h2 class="title">
10948: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
10949: <div class="toc">
10950: <p><b>Table of Contents</b></p>
10951: <dl>
10952: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
10953: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
10954: </dl>
10955: </div>
10956: <p>This section contains information on editing the pkgsrc
10957: guide itself.</p>
10958: <div class="sect1" lang="en">
10959: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10960: <a name="targets"></a>D.1. Make targets</h2></div></div></div>
10961: <p>The pkgsrc guide's source code is stored in
10962: <code class="filename">pkgsrc/doc/guide/files</code>, and several files
10963: are created from it:</p>
10964: <div class="itemizedlist"><ul type="disc">
10965: <li><p><code class="filename">pkgsrc/doc/pkgsrc.txt</code></p></li>
10966: <li><p><code class="filename">pkgsrc/doc/pkgsrc.html</code></p></li>
1.10 hubertf 10967: <li><p><a class="ulink" href="http://www.NetBSD.org/docs/pkgsrc/" target="_top">http://www.NetBSD.org/docs/pkgsrc/</a></p></li>
10968: <li><p><a class="ulink" href="http://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf" target="_top">http://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf</a>:
1.1 dsieger 10969: The PDF version of the pkgsrc guide.</p></li>
1.10 hubertf 10970: <li><p><a class="ulink" href="http://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps" target="_top">http://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps</a>:
1.1 dsieger 10971: PostScript version of the pkgsrc guide.</p></li>
10972: </ul></div>
10973: </div>
10974: <div class="sect1" lang="en">
10975: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10976: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
10977: <p>The procedure to edit the pkgsrc guide is:</p>
10978: <div class="procedure"><ol type="1">
10979: <li><p>Make sure you have the packages needed to
10980: regenerate the pkgsrc guide (and other XML-based NetBSD
10981: documentation) installed. These are <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/netbsd-doc/README.html" target="_top"><code class="filename">meta-pkgs/netbsd-doc</code></a> for creating the
10982: ASCII and HTML versions, and <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/netbsd-doc-print/README.html" target="_top"><code class="filename">meta-pkgs/netbsd-doc-print</code></a> for the
10983: PostScript and PDF versions. You will need both packages
10984: installed, to make sure documentation is consistent across all
10985: formats.</p></li>
1.10 hubertf 10986: <li><p>Run <span class="command"><strong>cd doc/guide</strong></span> to get to the
1.1 dsieger 10987: right directory. All further steps will take place
10988: here.</p></li>
10989: <li><p>Edit the XML file(s) in
10990: <code class="filename">files/</code>.</p></li>
1.10 hubertf 10991: <li><p>Run <span class="command"><strong>bmake</strong></span> to check the pkgsrc
1.1 dsieger 10992: guide for valid XML and to build the final output files. If you
10993: get any errors at this stage, you can just edit the files, as
10994: there are only symbolic links in the working directory, pointing
10995: to the files in <code class="filename">files/</code>.</p></li>
1.10 hubertf 10996: <li><p><span class="command"><strong>(cd files && cvs
1.1 dsieger 10997: commit)</strong></span></p></li>
1.10 hubertf 10998: <li><p>Run <span class="command"><strong>bmake clean && bmake</strong></span> to
1.1 dsieger 10999: regenerate the output files with the proper RCS
11000: Ids.</p></li>
11001: <li>
1.10 hubertf 11002: <p>Run <span class="command"><strong>bmake regen</strong></span> to install and
1.1 dsieger 11003: commit the files in both <code class="filename">pkgsrc/doc</code> and
11004: <code class="filename">htdocs</code>.</p>
11005: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
11006: <h3 class="title">Note</h3>
11007: <p>If you have added, removed or renamed some chapters,
1.10 hubertf 11008: you need to synchronize them using <span class="command"><strong>cvs add</strong></span> or
11009: <span class="command"><strong>cvs delete</strong></span> in the htdocs
1.1 dsieger 11010: directory.</p>
11011: </div>
11012: </li>
11013: </ol></div>
11014: </div>
11015: </div>
11016: </div></body>
11017: </html>
CVSweb <webmaster@jp.NetBSD.org>