Annotation of pkgsrc/doc/pkgsrc.html, revision 1.90
1.75 rillig 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2: <html>
1.1 grant 3: <head>
1.75 rillig 4: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
5: <title>The pkgsrc guide</title>
6: <link rel="stylesheet" href="/NetBSD.css" type="text/css">
7: <meta name="generator" content="DocBook XSL Stylesheets VX.X.X">
1.89 rillig 8: <meta name="description" content="pkgsrc is a centralized package management system for
9: Unix-like operating systems. This guide provides information for
10: users and developers of pkgsrc. It covers installation of binary
11: and source packages, creation of binary and source packages and
12: a high-level overview about the infrastructure.">
1.75 rillig 13: </head>
14: <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" lang="en">
15: <div class="titlepage">
16: <div>
17: <div><h1 class="title">
18: <a name="the-pkgsrc-guide"></a>The pkgsrc guide</h1></div>
19: <div><h2 class="subtitle">Documentation on the NetBSD packages system</h2></div>
20: <div><div class="authorgroup">
21: <div class="author">
22: <h3 class="author">
23: <span class="firstname">Alistair</span> <span class="surname">Crooks</span>
24: </h3>
25: <div class="affiliation"><div class="address"><p><code class="email"><<a href="mailto:agc@NetBSD.org">agc@NetBSD.org</a>></code></p></div></div>
26: </div>
27: <div class="author">
28: <h3 class="author">
29: <span class="firstname">Hubert</span> <span class="surname">Feyrer</span>
30: </h3>
31: <div class="affiliation"><div class="address"><p><code class="email"><<a href="mailto:hubertf@NetBSD.org">hubertf@NetBSD.org</a>></code></p></div></div>
32: </div>
33: <h3 class="corpauthor">
34: The pkgsrc Developers
35: </h3>
36: </div></div>
37: <div><p class="copyright">Copyright © 1994-2006 The NetBSD Foundation, Inc</p></div>
1.90 ! rillig 38: <div><p class="pubdate">$NetBSD: pkgsrc.xml,v 1.23 2006/09/19 17:50:38 rillig Exp $</p></div>
1.76 rillig 39: <div><div class="abstract">
1.75 rillig 40: <p class="title"><b>Abstract</b></p>
41: <p>pkgsrc is a centralized package management system for
42: Unix-like operating systems. This guide provides information for
43: users and developers of pkgsrc. It covers installation of binary
44: and source packages, creation of binary and source packages and
45: a high-level overview about the infrastructure.</p>
46: </div></div>
47: </div>
48: <hr>
49: </div>
50: <div class="toc">
51: <p><b>Table of Contents</b></p>
52: <dl>
53: <dt><span class="chapter"><a href="#introduction">1. What is pkgsrc?</a></span></dt>
54: <dd><dl>
55: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
1.82 rillig 56: <dd><dl>
57: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
58: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
59: </dl></dd>
1.75 rillig 60: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
61: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.88 wiz 62: <dd><dl><dt><span class="sect2"><a href="#term.roles">1.3.1. Roles involved in pkgsrc</a></span></dt></dl></dd>
1.75 rillig 63: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
64: </dl></dd>
65: <dt><span class="part"><a href="#users-guide">I. The pkgsrc user's guide</a></span></dt>
66: <dd><dl>
67: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
68: <dd><dl>
69: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
70: <dd><dl>
71: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
72: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
73: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
74: </dl></dd>
75: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
76: <dd><dl>
77: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
78: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
79: </dl></dd>
80: </dl></dd>
81: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
82: <dd><dl>
1.82 rillig 83: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
84: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
85: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
86: <dd><dl>
87: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
88: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
89: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
90: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
91: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
92: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
93: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75 rillig 94: </dl></dd>
95: </dl></dd>
96: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
97: <dd><dl>
98: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
99: <dd><dl>
100: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
101: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82 rillig 102: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
103: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
104: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
105: <dt><span class="sect2"><a href="#pkg_versions">4.1.6. Finding if newer versions of your installed packages are in pkgsrc</a></span></dt>
106: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
107: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75 rillig 108: </dl></dd>
109: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
110: <dd><dl>
111: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
112: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
113: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
114: </dl></dd>
115: </dl></dd>
116: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
117: <dd><dl>
118: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
119: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 120: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
1.88 wiz 121: <dd><dl>
1.89 rillig 122: <dt><span class="sect2"><a href="#selecting-the-compiler">5.3.1. Selecting the compiler</a></span></dt>
123: <dt><span class="sect2"><a href="#conf.cflags">5.3.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
124: <dt><span class="sect2"><a href="#conf.ldflags">5.3.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
1.88 wiz 125: </dl></dd>
1.78 rillig 126: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
127: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 128: </dl></dd>
129: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
130: <dd><dl>
131: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
132: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
133: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
134: <dd><dl>
135: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
136: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
137: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
138: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
139: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
140: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
141: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
142: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
143: </dl></dd>
144: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
145: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
146: </dl></dd>
1.90 ! rillig 147: <dt><span class="chapter"><a href="#files">7. Directory layout of the installed files</a></span></dt>
1.75 rillig 148: <dd><dl>
1.90 ! rillig 149: <dt><span class="sect1"><a href="#files.localbase">7.1. File system layout in <code class="literal">${PREFIX}</code></a></span></dt>
! 150: <dt><span class="sect1"><a href="#files.varbase">7.2. File system layout in <code class="literal">${VARBASE}</code></a></span></dt>
! 151: </dl></dd>
! 152: <dt><span class="chapter"><a href="#faq">8. Frequently Asked Questions</a></span></dt>
! 153: <dd><dl>
! 154: <dt><span class="sect1"><a href="#mailing-list-pointers">8.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
! 155: <dt><span class="sect1"><a href="#pkgviews-docs">8.2. Where's the pkgviews documentation?</a></span></dt>
! 156: <dt><span class="sect1"><a href="#faq-pkgtools">8.3. Utilities for package management (pkgtools)</a></span></dt>
! 157: <dt><span class="sect1"><a href="#non-root-pkgsrc">8.4. How to use pkgsrc as non-root</a></span></dt>
! 158: <dt><span class="sect1"><a href="#resume-transfers">8.5. How to resume transfers when fetching distfiles?</a></span></dt>
! 159: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">8.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
! 160: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">8.7. How can I install/use X.org from pkgsrc?</a></span></dt>
! 161: <dt><span class="sect1"><a href="#fetch-behind-firewall">8.8. How to fetch files from behind a firewall</a></span></dt>
! 162: <dt><span class="sect1"><a href="#passive-ftp">8.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
! 163: <dt><span class="sect1"><a href="#fetching-all-distfiles">8.10. How to fetch all distfiles at once</a></span></dt>
! 164: <dt><span class="sect1"><a href="#tmac.andoc-missing">8.11. What does “<span class="quote">Don't know how to make
1.75 rillig 165: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
1.90 ! rillig 166: <dt><span class="sect1"><a href="#bsd.own.mk-missing">8.12. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</a></span></dt>
! 167: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">8.13. Using 'sudo' with pkgsrc</a></span></dt>
! 168: <dt><span class="sect1"><a href="#faq.conf">8.14. How do I change the location of configuration files?</a></span></dt>
! 169: <dt><span class="sect1"><a href="#audit-packages">8.15. Automated security checks</a></span></dt>
! 170: <dt><span class="sect1"><a href="#ufaq-cflags">8.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
! 171: <dt><span class="sect1"><a href="#ufaq-fail">8.17. A package does not build. What shall I do?</a></span></dt>
! 172: <dt><span class="sect1"><a href="#faq.rcs-conflicts">8.18. What does “<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>” mean?</a></span></dt>
! 173: <dt><span class="sect1"><a href="#too-much-time">8.19. I have a little time to kill. What shall I do?</a></span></dt>
1.75 rillig 174: </dl></dd>
175: </dl></dd>
176: <dt><span class="part"><a href="#developers-guide">II. The pkgsrc developer's guide</a></span></dt>
177: <dd><dl>
1.90 ! rillig 178: <dt><span class="chapter"><a href="#creating">9. Creating a new pkgsrc package from scratch</a></span></dt>
! 179: <dt><span class="chapter"><a href="#components">10. Package components - files, directories and contents</a></span></dt>
1.75 rillig 180: <dd><dl>
1.90 ! rillig 181: <dt><span class="sect1"><a href="#components.Makefile">10.1. <code class="filename">Makefile</code></a></span></dt>
! 182: <dt><span class="sect1"><a href="#components.distinfo">10.2. <code class="filename">distinfo</code></a></span></dt>
! 183: <dt><span class="sect1"><a href="#components.patches">10.3. patches/*</a></span></dt>
! 184: <dd><dl>
! 185: <dt><span class="sect2"><a href="#components.patches.guidelines">10.3.1. Patching guidelines</a></span></dt>
! 186: <dt><span class="sect2"><a href="#components.patches.feedback">10.3.2. Feedback to the author</a></span></dt>
! 187: </dl></dd>
! 188: <dt><span class="sect1"><a href="#other-mandatory-files">10.4. Other mandatory files</a></span></dt>
! 189: <dt><span class="sect1"><a href="#components.optional">10.5. Optional files</a></span></dt>
! 190: <dd><dl>
! 191: <dt><span class="sect2"><a href="#components.optional.bin">10.5.1. Files affecting the binary package</a></span></dt>
! 192: <dt><span class="sect2"><a href="#components.optional.build">10.5.2. Files affecting the build process</a></span></dt>
! 193: <dt><span class="sect2"><a href="#components.optional.none">10.5.3. Files affecting nothing at all</a></span></dt>
! 194: </dl></dd>
! 195: <dt><span class="sect1"><a href="#work-dir">10.6. <code class="filename">work*</code></a></span></dt>
! 196: <dt><span class="sect1"><a href="#files-dir">10.7. <code class="filename">files/*</code></a></span></dt>
! 197: </dl></dd>
! 198: <dt><span class="chapter"><a href="#makefile">11. Programming in <code class="filename">Makefile</code>s</a></span></dt>
! 199: <dd><dl>
! 200: <dt><span class="sect1"><a href="#makefile.variables">11.1. <code class="filename">Makefile</code> variables</a></span></dt>
! 201: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">11.1.1. Naming conventions</a></span></dt></dl></dd>
! 202: <dt><span class="sect1"><a href="#makefile.code">11.2. Code snippets</a></span></dt>
! 203: <dd><dl>
! 204: <dt><span class="sect2"><a href="#adding-to-list">11.2.1. Adding things to a list</a></span></dt>
! 205: <dt><span class="sect2"><a href="#converting-internal-to-external">11.2.2. Converting an internal list into an external list</a></span></dt>
! 206: <dt><span class="sect2"><a href="#passing-variable-to-shell">11.2.3. Passing variables to a shell command</a></span></dt>
! 207: <dt><span class="sect2"><a href="#quoting-guideline">11.2.4. Quoting guideline</a></span></dt>
! 208: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">11.2.5. Workaround for a bug in BSD Make</a></span></dt>
! 209: </dl></dd>
! 210: </dl></dd>
! 211: <dt><span class="chapter"><a href="#plist">12. PLIST issues</a></span></dt>
! 212: <dd><dl>
! 213: <dt><span class="sect1"><a href="#rcs-id">12.1. RCS ID</a></span></dt>
! 214: <dt><span class="sect1"><a href="#automatic-plist-generation">12.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
! 215: <dt><span class="sect1"><a href="#print-PLIST">12.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
! 216: <dt><span class="sect1"><a href="#plist.misc">12.4. Variable substitution in PLIST</a></span></dt>
! 217: <dt><span class="sect1"><a href="#manpage-compression">12.5. Man page compression</a></span></dt>
! 218: <dt><span class="sect1"><a href="#using-PLIST_SRC">12.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
! 219: <dt><span class="sect1"><a href="#platform-specific-plist">12.7. Platform-specific and differing PLISTs</a></span></dt>
! 220: <dt><span class="sect1"><a href="#faq.common-dirs">12.8. Sharing directories between packages</a></span></dt>
! 221: </dl></dd>
! 222: <dt><span class="chapter"><a href="#buildlink">13. Buildlink methodology</a></span></dt>
! 223: <dd><dl>
! 224: <dt><span class="sect1"><a href="#converting-to-buildlink3">13.1. Converting packages to use buildlink3</a></span></dt>
! 225: <dt><span class="sect1"><a href="#creating-buildlink3.mk">13.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
! 226: <dd><dl>
! 227: <dt><span class="sect2"><a href="#anatomy-of-bl3">13.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
! 228: <dt><span class="sect2"><a href="#updating-buildlink-depends">13.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>
! 229: </dl></dd>
! 230: <dt><span class="sect1"><a href="#writing-builtin.mk">13.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
! 231: <dd><dl>
! 232: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">13.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
! 233: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">13.3.2. Global preferences for native or pkgsrc software</a></span></dt>
! 234: </dl></dd>
! 235: </dl></dd>
! 236: <dt><span class="chapter"><a href="#pkginstall">14. The pkginstall framework</a></span></dt>
! 237: <dd><dl>
! 238: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">14.1. Files and directories outside the installation prefix</a></span></dt>
! 239: <dd><dl>
! 240: <dt><span class="sect2"><a href="#dirs-outside-prefix">14.1.1. Directory manipulation</a></span></dt>
! 241: <dt><span class="sect2"><a href="#files-outside-prefix">14.1.2. File manipulation</a></span></dt>
! 242: </dl></dd>
! 243: <dt><span class="sect1"><a href="#conf-files">14.2. Configuration files</a></span></dt>
! 244: <dd><dl>
! 245: <dt><span class="sect2"><a href="#conf-files-sysconfdir">14.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
! 246: <dt><span class="sect2"><a href="#conf-files-configure">14.2.2. Telling the software where configuration files are</a></span></dt>
! 247: <dt><span class="sect2"><a href="#conf-files-patching">14.2.3. Patching installations</a></span></dt>
! 248: <dt><span class="sect2"><a href="#conf-files-disable">14.2.4. Disabling handling of configuration files</a></span></dt>
! 249: </dl></dd>
! 250: <dt><span class="sect1"><a href="#rcd-scripts">14.3. System startup scripts</a></span></dt>
! 251: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">14.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
! 252: <dt><span class="sect1"><a href="#users-and-groups">14.4. System users and groups</a></span></dt>
! 253: <dt><span class="sect1"><a href="#shells">14.5. System shells</a></span></dt>
! 254: <dd><dl><dt><span class="sect2"><a href="#shells-disable">14.5.1. Disabling shell registration</a></span></dt></dl></dd>
! 255: <dt><span class="sect1"><a href="#fonts">14.6. Fonts</a></span></dt>
! 256: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">14.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
! 257: </dl></dd>
! 258: <dt><span class="chapter"><a href="#options">15. Options handling</a></span></dt>
! 259: <dd><dl>
! 260: <dt><span class="sect1"><a href="#global-default-options">15.1. Global default options</a></span></dt>
! 261: <dt><span class="sect1"><a href="#converting-to-options">15.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
! 262: <dt><span class="sect1"><a href="#option-names">15.3. Option Names</a></span></dt>
! 263: </dl></dd>
! 264: <dt><span class="chapter"><a href="#build">16. The build process</a></span></dt>
! 265: <dd><dl>
! 266: <dt><span class="sect1"><a href="#build.intro">16.1. Introduction</a></span></dt>
! 267: <dt><span class="sect1"><a href="#build.prefix">16.2. Program location</a></span></dt>
! 268: <dt><span class="sect1"><a href="#build.builddirs">16.3. Directories used during the build process</a></span></dt>
! 269: <dt><span class="sect1"><a href="#build.running">16.4. Running a phase</a></span></dt>
! 270: <dt><span class="sect1"><a href="#build.fetch">16.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
! 271: <dd><dl>
! 272: <dt><span class="sect2"><a href="#build.fetch.what">16.5.1. What to fetch and where to get it from</a></span></dt>
! 273: <dt><span class="sect2"><a href="#build.fetch.how">16.5.2. How are the files fetched?</a></span></dt>
! 274: </dl></dd>
! 275: <dt><span class="sect1"><a href="#build.checksum">16.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
! 276: <dt><span class="sect1"><a href="#build.extract">16.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
! 277: <dt><span class="sect1"><a href="#build.patch">16.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
! 278: <dt><span class="sect1"><a href="#build.tools">16.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
! 279: <dt><span class="sect1"><a href="#build.wrapper">16.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
! 280: <dt><span class="sect1"><a href="#build.configure">16.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
! 281: <dt><span class="sect1"><a href="#build.build">16.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
! 282: <dt><span class="sect1"><a href="#build.test">16.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
! 283: <dt><span class="sect1"><a href="#build.install">16.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
! 284: <dt><span class="sect1"><a href="#build.package">16.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
! 285: <dt><span class="sect1"><a href="#build.clean">16.16. Cleaning up</a></span></dt>
! 286: <dt><span class="sect1"><a href="#build.helpful-targets">16.17. Other helpful targets</a></span></dt>
! 287: </dl></dd>
! 288: <dt><span class="chapter"><a href="#tools">17. Tools needed for building or running</a></span></dt>
! 289: <dd><dl>
! 290: <dt><span class="sect1"><a href="#pkgsrc-tools">17.1. Tools for pkgsrc builds</a></span></dt>
! 291: <dt><span class="sect1"><a href="#package-tools">17.2. Tools needed by packages</a></span></dt>
! 292: <dt><span class="sect1"><a href="#platform-tools">17.3. Tools provided by platforms</a></span></dt>
! 293: </dl></dd>
! 294: <dt><span class="chapter"><a href="#fixes">18. Making your package work</a></span></dt>
! 295: <dd><dl>
! 296: <dt><span class="sect1"><a href="#general-operation">18.1. General operation</a></span></dt>
! 297: <dd><dl>
! 298: <dt><span class="sect2"><a href="#portability-of-packages">18.1.1. Portability of packages</a></span></dt>
! 299: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">18.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
! 300: <dt><span class="sect2"><a href="#user-interaction">18.1.3. User interaction</a></span></dt>
! 301: <dt><span class="sect2"><a href="#handling-licenses">18.1.4. Handling licenses</a></span></dt>
! 302: <dt><span class="sect2"><a href="#restricted-packages">18.1.5. Restricted packages</a></span></dt>
! 303: <dt><span class="sect2"><a href="#dependencies">18.1.6. Handling dependencies</a></span></dt>
! 304: <dt><span class="sect2"><a href="#conflicts">18.1.7. Handling conflicts with other packages</a></span></dt>
! 305: <dt><span class="sect2"><a href="#not-building-packages">18.1.8. Packages that cannot or should not be built</a></span></dt>
! 306: <dt><span class="sect2"><a href="#undeletable-packages">18.1.9. Packages which should not be deleted, once installed</a></span></dt>
! 307: <dt><span class="sect2"><a href="#security-handling">18.1.10. Handling packages with security problems</a></span></dt>
! 308: <dt><span class="sect2"><a href="#bumping-pkgrevision">18.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
! 309: <dt><span class="sect2"><a href="#fixes.subst">18.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
! 310: </dl></dd>
! 311: <dt><span class="sect1"><a href="#fixes.fetch">18.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
! 312: <dd><dl>
! 313: <dt><span class="sect2"><a href="#no-plain-download">18.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
! 314: <dt><span class="sect2"><a href="#modified-distfiles-same-name">18.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
! 315: </dl></dd>
! 316: <dt><span class="sect1"><a href="#fixes.configure">18.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
! 317: <dd><dl>
! 318: <dt><span class="sect2"><a href="#fixes.libtool">18.3.1. Shared libraries - libtool</a></span></dt>
! 319: <dt><span class="sect2"><a href="#using-libtool">18.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
! 320: <dt><span class="sect2"><a href="#autoconf-automake">18.3.3. GNU Autoconf/Automake</a></span></dt>
! 321: </dl></dd>
! 322: <dt><span class="sect1"><a href="#programming-languages">18.4. Programming languages</a></span></dt>
! 323: <dd><dl>
! 324: <dt><span class="sect2"><a href="#basic-programming-languages">18.4.1. C, C++, and Fortran</a></span></dt>
! 325: <dt><span class="sect2"><a href="#java-programming-language">18.4.2. Java</a></span></dt>
! 326: <dt><span class="sect2"><a href="#perl-scripts">18.4.3. Packages containing perl scripts</a></span></dt>
! 327: <dt><span class="sect2"><a href="#other-programming-languages">18.4.4. Other programming languages</a></span></dt>
! 328: </dl></dd>
! 329: <dt><span class="sect1"><a href="#fixes.build">18.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
! 330: <dd><dl>
! 331: <dt><span class="sect2"><a href="#fixes.build.cpp">18.5.1. Compiling C and C++ code conditionally</a></span></dt>
! 332: <dt><span class="sect2"><a href="#compiler-bugs">18.5.2. How to handle compiler bugs</a></span></dt>
! 333: <dt><span class="sect2"><a href="#undefined-reference">18.5.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
! 334: <dt><span class="sect2"><a href="#out-of-memory">18.5.4. Running out of memory</a></span></dt>
! 335: </dl></dd>
! 336: <dt><span class="sect1"><a href="#fixes.install">18.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
! 337: <dd><dl>
! 338: <dt><span class="sect2"><a href="#install-scripts">18.6.1. Creating needed directories</a></span></dt>
! 339: <dt><span class="sect2"><a href="#where-to-install-documentation">18.6.2. Where to install documentation</a></span></dt>
! 340: <dt><span class="sect2"><a href="#installing-score-files">18.6.3. Installing score files</a></span></dt>
! 341: <dt><span class="sect2"><a href="#hardcoded-paths">18.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
! 342: <dt><span class="sect2"><a href="#perl-modules">18.6.5. Packages installing perl modules</a></span></dt>
! 343: <dt><span class="sect2"><a href="#faq.info-files">18.6.6. Packages installing info files</a></span></dt>
! 344: <dt><span class="sect2"><a href="#manpages">18.6.7. Packages installing man pages</a></span></dt>
! 345: <dt><span class="sect2"><a href="#gconf2-data-files">18.6.8. Packages installing GConf2 data files</a></span></dt>
! 346: <dt><span class="sect2"><a href="#scrollkeeper-data-files">18.6.9. Packages installing scrollkeeper data files</a></span></dt>
! 347: <dt><span class="sect2"><a href="#x11-fonts">18.6.10. Packages installing X11 fonts</a></span></dt>
! 348: <dt><span class="sect2"><a href="#gtk2-modules">18.6.11. Packages installing GTK2 modules</a></span></dt>
! 349: <dt><span class="sect2"><a href="#sgml-xml-data">18.6.12. Packages installing SGML or XML data</a></span></dt>
! 350: <dt><span class="sect2"><a href="#mime-database">18.6.13. Packages installing extensions to the MIME database</a></span></dt>
! 351: <dt><span class="sect2"><a href="#intltool">18.6.14. Packages using intltool</a></span></dt>
! 352: <dt><span class="sect2"><a href="#startup-scripts">18.6.15. Packages installing startup scripts</a></span></dt>
! 353: <dt><span class="sect2"><a href="#tex-packages">18.6.16. Packages installing TeX modules</a></span></dt>
! 354: <dt><span class="sect2"><a href="#emulation-packages">18.6.17. Packages supporting running binaries in
1.87 wiz 355: emulation</a></span></dt>
1.90 ! rillig 356: <dt><span class="sect2"><a href="#hicolor-theme">18.6.18. Packages installing hicolor theme icons</a></span></dt>
! 357: <dt><span class="sect2"><a href="#desktop-files">18.6.19. Packages installing desktop files</a></span></dt>
1.77 rillig 358: </dl></dd>
1.90 ! rillig 359: <dt><span class="sect1"><a href="#punting">18.7. Marking packages as having problems</a></span></dt>
1.77 rillig 360: </dl></dd>
1.90 ! rillig 361: <dt><span class="chapter"><a href="#debug">19. Debugging</a></span></dt>
! 362: <dt><span class="chapter"><a href="#submit">20. Submitting and Committing</a></span></dt>
1.77 rillig 363: <dd><dl>
1.90 ! rillig 364: <dt><span class="sect1"><a href="#submitting-binary-packages">20.1. Submitting binary packages</a></span></dt>
! 365: <dt><span class="sect1"><a href="#submitting-your-package">20.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
! 366: <dt><span class="sect1"><a href="#general-notes-for-changes">20.3. General notes when adding, updating, or removing packages</a></span></dt>
! 367: <dt><span class="sect1"><a href="#committing-importing">20.4. Committing: Importing a package into CVS</a></span></dt>
! 368: <dt><span class="sect1"><a href="#updating-package">20.5. Updating a package to a newer version</a></span></dt>
! 369: <dt><span class="sect1"><a href="#moving-package">20.6. Moving a package in pkgsrc</a></span></dt>
! 370: </dl></dd>
! 371: <dt><span class="chapter"><a href="#devfaq">21. Frequently Asked Questions</a></span></dt>
! 372: <dt><span class="chapter"><a href="#gnome">22. GNOME packaging and porting</a></span></dt>
! 373: <dd><dl>
! 374: <dt><span class="sect1"><a href="#meta-packages">22.1. Meta packages</a></span></dt>
! 375: <dt><span class="sect1"><a href="#new-package">22.2. Packaging a GNOME application</a></span></dt>
! 376: <dt><span class="sect1"><a href="#full-update">22.3. Updating GNOME to a newer version</a></span></dt>
! 377: <dt><span class="sect1"><a href="#patching">22.4. Patching guidelines</a></span></dt>
1.85 jmmv 378: </dl></dd>
1.75 rillig 379: </dl></dd>
380: <dt><span class="part"><a href="#infrastructure">III. The pkgsrc infrastructure internals</a></span></dt>
381: <dd><dl>
1.90 ! rillig 382: <dt><span class="chapter"><a href="#infr.design">23. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 383: <dd><dl>
1.90 ! rillig 384: <dt><span class="sect1"><a href="#infr.vardef">23.1. The meaning of variable definitions</a></span></dt>
! 385: <dt><span class="sect1"><a href="#infr.vardef.problems">23.2. Avoiding problems before they arise</a></span></dt>
! 386: <dt><span class="sect1"><a href="#infr.var">23.3. Variable evaluation</a></span></dt>
1.81 rillig 387: <dd><dl>
1.90 ! rillig 388: <dt><span class="sect2"><a href="#infr.var.load">23.3.1. At load time</a></span></dt>
! 389: <dt><span class="sect2"><a href="#infr.var.run">23.3.2. At runtime</a></span></dt>
1.81 rillig 390: </dl></dd>
1.90 ! rillig 391: <dt><span class="sect1"><a href="#infr.varspec">23.4. How can variables be specified?</a></span></dt>
! 392: <dt><span class="sect1"><a href="#infr.design.intf">23.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 393: <dd><dl>
1.90 ! rillig 394: <dt><span class="sect2"><a href="#infr.design.intf.proc">23.5.1. Procedures with parameters</a></span></dt>
! 395: <dt><span class="sect2"><a href="#infr.design.intf.action">23.5.2. Actions taken on behalf of parameters</a></span></dt>
1.75 rillig 396: </dl></dd>
1.90 ! rillig 397: <dt><span class="sect1"><a href="#infr.order">23.6. The order in which files are loaded</a></span></dt>
1.75 rillig 398: <dd><dl>
1.90 ! rillig 399: <dt><span class="sect2"><a href="#infr.order.prefs">23.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
! 400: <dt><span class="sect2"><a href="#infr.order.pkg">23.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75 rillig 401: </dl></dd>
402: </dl></dd>
1.90 ! rillig 403: <dt><span class="chapter"><a href="#regression">24. Regression tests</a></span></dt>
1.75 rillig 404: <dd><dl>
1.90 ! rillig 405: <dt><span class="sect1"><a href="#regression.descr">24.1. The regression tests framework</a></span></dt>
! 406: <dt><span class="sect1"><a href="#regression.run">24.2. Running the regression tests</a></span></dt>
! 407: <dt><span class="sect1"><a href="#regression.new">24.3. Adding a new regression test</a></span></dt>
1.75 rillig 408: <dd><dl>
1.90 ! rillig 409: <dt><span class="sect2"><a href="#regression.fun.override">24.3.1. Overridable functions</a></span></dt>
! 410: <dt><span class="sect2"><a href="#regression.fun.helper">24.3.2. Helper functions</a></span></dt>
1.75 rillig 411: </dl></dd>
412: </dl></dd>
1.90 ! rillig 413: <dt><span class="chapter"><a href="#porting">25. Porting pkgsrc</a></span></dt>
1.75 rillig 414: <dd><dl>
1.90 ! rillig 415: <dt><span class="sect1"><a href="#porting.opsys">25.1. Porting pkgsrc to a new operating system</a></span></dt>
! 416: <dt><span class="sect1"><a href="#porting.compiler">25.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 417: </dl></dd>
418: </dl></dd>
419: <dt><span class="appendix"><a href="#examples">A. A simple example package: bison</a></span></dt>
420: <dd><dl>
421: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
422: <dd><dl>
423: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
424: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
425: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
426: <dt><span class="sect2"><a href="#checking-package-with-pkglint">A.1.4. Checking a package with <span><strong class="command">pkglint</strong></span></a></span></dt>
427: </dl></dd>
428: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
429: </dl></dd>
430: <dt><span class="appendix"><a href="#logs">B. Build logs</a></span></dt>
431: <dd><dl>
432: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
433: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
434: </dl></dd>
1.76 rillig 435: <dt><span class="appendix"><a href="#ftp-layout">C. Directory layout of the pkgsrc FTP server</a></span></dt>
436: <dd><dl>
437: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
438: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
439: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
440: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
441: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
442: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
443: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
444: source packages</a></span></dt>
445: </dl></dd>
1.75 rillig 446: <dt><span class="appendix"><a href="#editing">D. Editing guidelines for the pkgsrc guide</a></span></dt>
447: <dd><dl>
1.79 rillig 448: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75 rillig 449: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
450: </dl></dd>
451: </dl>
452: </div>
1.82 rillig 453: <div class="list-of-tables">
454: <p><b>List of Tables</b></p>
455: <dl>
456: <dt>1.1. <a href="#supported-platforms">Platforms supported by pkgsrc</a>
457: </dt>
458: <dt>3.1. <a href="#binary-kits">Binary kits and available packages</a>
459: </dt>
1.90 ! rillig 460: <dt>10.1. <a href="#patch-examples">Patching examples</a>
1.85 jmmv 461: </dt>
1.90 ! rillig 462: <dt>22.1. <a href="#plist-handling">PLIST handling for GNOME packages</a>
1.85 jmmv 463: </dt>
1.82 rillig 464: </dl>
465: </div>
1.75 rillig 466: <div class="chapter" lang="en">
467: <div class="titlepage"><div><div><h2 class="title">
468: <a name="introduction"></a>Chapter 1. What is pkgsrc?</h2></div></div></div>
469: <div class="toc">
470: <p><b>Table of Contents</b></p>
471: <dl>
472: <dt><span class="sect1"><a href="#introduction-section">1.1. Introduction</a></span></dt>
1.82 rillig 473: <dd><dl>
474: <dt><span class="sect2"><a href="#why-pkgsrc">1.1.1. Why pkgsrc?</a></span></dt>
475: <dt><span class="sect2"><a href="#intro.platforms">1.1.2. Supported platforms</a></span></dt>
476: </dl></dd>
1.75 rillig 477: <dt><span class="sect1"><a href="#overview">1.2. Overview</a></span></dt>
478: <dt><span class="sect1"><a href="#terminology">1.3. Terminology</a></span></dt>
1.88 wiz 479: <dd><dl><dt><span class="sect2"><a href="#term.roles">1.3.1. Roles involved in pkgsrc</a></span></dt></dl></dd>
1.75 rillig 480: <dt><span class="sect1"><a href="#typography">1.4. Typography</a></span></dt>
481: </dl>
482: </div>
483: <div class="sect1" lang="en">
484: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
485: <a name="introduction-section"></a>1.1. Introduction</h2></div></div></div>
1.82 rillig 486: <p>There is a lot of software freely available for Unix-based
487: systems, which is usually available in form of the source code. Before
488: such software can be used, it needs to be configured to the local
489: system, compiled and installed, and this is exactly what The NetBSD
490: Packages Collection (pkgsrc) does. pkgsrc also has some basic commands
491: to handle binary packages, so that not every user has to build the
492: packages for himself, which is a time-costly task.</p>
1.75 rillig 493: <p>pkgsrc currently contains several thousand packages,
494: including:</p>
495: <div class="itemizedlist"><ul type="disc">
1.76 rillig 496: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/apache/README.html" target="_top"><code class="filename">www/apache</code></a> - The Apache
1.75 rillig 497: web server</p></li>
1.83 wiz 498: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a> - The Firefox
1.75 rillig 499: web browser</p></li>
1.76 rillig 500: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome/README.html" target="_top"><code class="filename">meta-pkgs/gnome</code></a> - The GNOME
1.75 rillig 501: Desktop Environment</p></li>
1.76 rillig 502: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/kde3/README.html" target="_top"><code class="filename">meta-pkgs/kde3</code></a> - The K
1.75 rillig 503: Desktop Environment</p></li>
504: </ul></div>
505: <p>...just to name a few.</p>
506: <p>pkgsrc has built-in support for handling varying dependencies,
507: such as pthreads and X11, and extended features such as IPv6 support on
508: a range of platforms.</p>
1.82 rillig 509: <div class="sect2" lang="en">
510: <div class="titlepage"><div><div><h3 class="title">
511: <a name="why-pkgsrc"></a>1.1.1. Why pkgsrc?</h3></div></div></div>
512: <p>
513: pkgsrc provides the following key features:
514: </p>
515: <div class="itemizedlist"><ul type="disc">
516: <li><p>Easy building of software from source as well as the creation
517: and installation of binary packages. The source and latest
518: patches are retrieved from a master or mirror download site, checksum
519: verified, then built on your system. Support for binary-only
520: distributions is available for both native platforms and NetBSD
521: emulated platforms.</p></li>
522: <li><p>All packages are installed in a consistent directory tree,
523: including binaries, libraries, man pages and other
524: documentation.</p></li>
525: <li><p>Package dependencies, including when performing package updates,
526: are handled automatically. The configuration files of various
527: packages are handled automatically during updates, so local changes
528: are preserved.</p></li>
529: <li><p>Like NetBSD, pkgsrc is designed with portability in mind and
530: consists of highly portable code. This allows the greatest speed of
531: development when porting to new a platform. This portability also
532: ensures that pkgsrc is <span class="emphasis"><em>consistent across all
533: platforms</em></span>.</p></li>
534: <li><p>The installation prefix, acceptable software licenses,
535: international encryption requirements and build-time options for a
536: large number of packages are all set in a simple, central
537: configuration file.</p></li>
538: <li><p>The entire source (not including the distribution files) is
539: freely available under a BSD license, so you may extend and adapt
540: pkgsrc to your needs. Support for local packages and patches is
541: available right out of the box, so you can configure it specifically
542: for your environment.</p></li>
543: </ul></div>
544: </div>
545: <div class="sect2" lang="en">
546: <div class="titlepage"><div><div><h3 class="title">
547: <a name="intro.platforms"></a>1.1.2. Supported platforms</h3></div></div></div>
548: <p>pkgsrc consists of both a source distribution and a binary
549: distribution for these operating systems. After retrieving the required
550: source or binaries, you can be up and running with pkgsrc in just
551: minutes!</p>
1.75 rillig 552: <p>pkgsrc was derived from FreeBSD's ports system, and
553: initially developed for NetBSD only. Since then, pkgsrc has
554: grown a lot, and now supports the following platforms:</p>
1.82 rillig 555: <div class="table">
556: <a name="supported-platforms"></a><p class="title"><b>Table 1.1. Platforms supported by pkgsrc</b></p>
1.89 rillig 557: <table summary="Platforms supported by pkgsrc" border="1">
1.82 rillig 558: <colgroup>
559: <col>
560: <col>
561: </colgroup>
562: <thead><tr>
563: <th>Platform</th>
564: <th>Date Support Added</th>
565: </tr></thead>
566: <tbody>
567: <tr>
568: <td><a href="http://www.NetBSD.org/" target="_top">NetBSD</a></td>
569: <td align="center">Aug 1997</td>
570: </tr>
571: <tr>
572: <td><a href="http://wwws.sun.com/software/solaris/" target="_top">Solaris</a></td>
573: <td align="center">Mar 1999</td>
574: </tr>
575: <tr>
576: <td><a href="http://www.kernel.org/" target="_top">Linux</a></td>
577: <td align="center">Jun 1999</td>
578: </tr>
579: <tr>
580: <td>
581: <a href="http://developer.apple.com/darwin/" target="_top">Darwin</a>
582: (<a href="http://developer.apple.com/macosx/" target="_top">Mac OS X</a>)
583: </td>
584: <td align="center">Oct 2001</td>
585: </tr>
586: <tr>
587: <td><a href="http://www.freebsd.org/" target="_top">FreeBSD</a></td>
588: <td align="center">Nov 2002</td>
589: </tr>
590: <tr>
591: <td><a href="http://www.openbsd.org/" target="_top">OpenBSD</a></td>
592: <td align="center">Nov 2002</td>
593: </tr>
594: <tr>
595: <td><a href="http://www.sgi.com/software/irix/" target="_top">IRIX</a></td>
596: <td align="center">Dec 2002</td>
597: </tr>
598: <tr>
599: <td>BSD/OS</td>
600: <td align="center">Dec 2003</td>
601: </tr>
602: <tr>
603: <td><a href="http://www-1.ibm.com/servers/aix/" target="_top">AIX</a></td>
604: <td align="center">Dec 2003</td>
605: </tr>
606: <tr>
607: <td>
608: <a href="http://www.microsoft.com/windows/sfu/" target="_top">Interix</a>
609: (Microsoft Windows Services for Unix)
610: </td>
611: <td align="center">Mar 2004</td>
612: </tr>
613: <tr>
614: <td><a href="http://www.dragonflybsd.org/" target="_top">DragonFlyBSD</a></td>
615: <td align="center">Oct 2004</td>
616: </tr>
617: <tr>
618: <td><a href="http://www.tru64.org/" target="_top">OSF/1</a></td>
619: <td align="center">Nov 2004</td>
620: </tr>
621: </tbody>
1.89 rillig 622: </table>
1.82 rillig 623: </div>
624: </div>
1.75 rillig 625: </div>
626: <div class="sect1" lang="en">
627: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
628: <a name="overview"></a>1.2. Overview</h2></div></div></div>
629: <p>This document is divided into three parts. The first,
630: <a href="#users-guide" title="Part I. The pkgsrc user's guide">The pkgsrc user's guide</a>,
631: describes how one can use one of the packages in the Package
632: Collection, either by installing a precompiled binary package,
633: or by building one's own copy using the NetBSD package system.
634: The second part, <a href="#developers-guide" title="Part II. The pkgsrc developer's guide">The pkgsrc developer's guide</a>, explains how to prepare a
635: package so it can be easily built by other NetBSD users without
636: knowing about the package's building details. The third part,
637: <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">The pkgsrc infrastructure internals</a>
638: is intended for those who want to understand how pkgsrc is
639: implemented.</p>
640: <p>This document is available in various formats:
641: <span class="simplelist"><a href="index.html" target="_top">HTML</a>, <a href="pkgsrc.pdf" target="_top">PDF</a>, <a href="pkgsrc.ps" target="_top">PS</a>, <a href="pkgsrc.txt" target="_top">TXT</a></span>.</p>
642: </div>
643: <div class="sect1" lang="en">
644: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
645: <a name="terminology"></a>1.3. Terminology</h2></div></div></div>
646: <p>There has been a lot of talk about “<span class="quote">ports</span>”,
647: “<span class="quote">packages</span>”, etc. so far. Here is a description of all the
648: terminology used within this document.</p>
649: <div class="variablelist"><dl>
650: <dt><span class="term">Package</span></dt>
651: <dd><p>A set of files and building instructions
652: that describe what's necessary
653: to build a certain piece of software using
654: pkgsrc. Packages are traditionally stored under
1.76 rillig 655: <code class="filename">/usr/pkgsrc</code>.</p></dd>
1.75 rillig 656: <dt><span class="term">The NetBSD package system</span></dt>
1.87 wiz 657: <dd><p>This is the former name of “<span class="quote">pkgsrc</span>”. It
658: is part of the NetBSD operating system and can be bootstrapped
659: to run on non-NetBSD operating systems as well. It handles
660: building (compiling), installing, and removing of
661: packages.</p></dd>
1.75 rillig 662: <dt><span class="term">Distfile</span></dt>
663: <dd><p>This term describes the file or files that are
664: provided by the author of the piece of software to
665: distribute his work. All the changes necessary to build on
666: NetBSD are reflected in the corresponding package. Usually
667: the distfile is in the form of a compressed tar-archive,
668: but other types are possible, too. Distfiles are usually
669: stored below
1.76 rillig 670: <code class="filename">/usr/pkgsrc/distfiles</code>.</p></dd>
1.75 rillig 671: <dt><span class="term">Port</span></dt>
672: <dd><p>This is the term used by FreeBSD and OpenBSD people
673: for what we call a package.
674: In NetBSD terminology, “<span class="quote">port</span>” refers to a different
675: architecture.</p></dd>
676: <dt><span class="term">Precompiled/binary package</span></dt>
677: <dd>
678: <p>A set of binaries built with pkgsrc from a distfile
1.76 rillig 679: and stuffed together in a single <code class="filename">.tgz</code>
1.75 rillig 680: file so it can be installed on machines of the same
681: machine architecture without the need to
682: recompile. Packages are usually generated in
1.76 rillig 683: <code class="filename">/usr/pkgsrc/packages</code>; there is also
1.75 rillig 684: an archive on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/" target="_top">ftp.NetBSD.org</a>.</p>
685: <p>Sometimes, this is referred to by the term “<span class="quote">package</span>” too,
686: especially in the context of precompiled packages.</p>
687: </dd>
688: <dt><span class="term">Program</span></dt>
1.88 wiz 689: <dd><p>The piece of software to be installed which will be
690: constructed from all the files in the distfile by the
691: actions defined in the corresponding package.</p></dd>
1.75 rillig 692: </dl></div>
693: <div class="sect2" lang="en">
694: <div class="titlepage"><div><div><h3 class="title">
1.88 wiz 695: <a name="term.roles"></a>1.3.1. Roles involved in pkgsrc</h3></div></div></div>
1.75 rillig 696: <div class="variablelist"><dl>
697: <dt><span class="term">pkgsrc users</span></dt>
698: <dd>
699: <p>The
700: pkgsrc users are people who use the packages provided by pkgsrc.
701: Typically they are system administrators. The people using the
702: software that is inside the packages (maybe called “<span class="quote">end
703: users</span>”) are not covered by the pkgsrc guide.</p>
704: <p>There are two kinds of pkgsrc users: Some only want to
705: install pre-built binary packages. Others build the pkgsrc
706: packages from source, either for installing them directly or for
707: building binary packages themselves. For pkgsrc users <a href="#users-guide" title="Part I. The pkgsrc user's guide">Part I, “The pkgsrc user's guide”</a> should provide all necessary
708: documentation.</p>
709: </dd>
710: <dt><span class="term">package maintainers</span></dt>
711: <dd><p>A
712: package maintainer creates packages as described in <a href="#developers-guide" title="Part II. The pkgsrc developer's guide">Part II, “The pkgsrc developer's guide”</a>.</p></dd>
713: <dt><span class="term">infrastructure developers</span></dt>
714: <dd><p>These people are involved in all those files
1.76 rillig 715: that live in the <code class="filename">mk/</code> directory and below.
1.75 rillig 716: Only these people should need to read through <a href="#infrastructure" title="Part III. The pkgsrc infrastructure internals">Part III, “The pkgsrc infrastructure internals”</a>, though others might be curious,
717: too.</p></dd>
718: </dl></div>
719: </div>
720: </div>
721: <div class="sect1" lang="en">
722: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
723: <a name="typography"></a>1.4. Typography</h2></div></div></div>
724: <p>When giving examples for commands, shell prompts are used to
725: show if the command should/can be issued as root, or if
726: “<span class="quote">normal</span>” user privileges are sufficient. We use a
727: <code class="prompt">#</code> for root's shell prompt, and a <code class="prompt">%</code> for users'
728: shell prompt, assuming they use the C-shell or tcsh.</p>
729: </div>
730: </div>
731: <div class="part" lang="en">
732: <div class="titlepage"><div><div><h1 class="title">
733: <a name="users-guide"></a>Part I. The pkgsrc user's guide</h1></div></div></div>
734: <div class="toc">
735: <p><b>Table of Contents</b></p>
736: <dl>
737: <dt><span class="chapter"><a href="#getting">2. Where to get pkgsrc and how to keep it up-to-date</a></span></dt>
738: <dd><dl>
739: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
740: <dd><dl>
741: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
742: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
743: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
744: </dl></dd>
745: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
746: <dd><dl>
747: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
748: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
749: </dl></dd>
750: </dl></dd>
751: <dt><span class="chapter"><a href="#platforms">3. Using pkgsrc on systems other than NetBSD</a></span></dt>
752: <dd><dl>
1.82 rillig 753: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
754: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
755: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
756: <dd><dl>
757: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
758: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
759: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
760: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
761: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
762: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
763: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75 rillig 764: </dl></dd>
765: </dl></dd>
766: <dt><span class="chapter"><a href="#using">4. Using pkgsrc</a></span></dt>
767: <dd><dl>
768: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
769: <dd><dl>
770: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
771: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82 rillig 772: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
773: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
774: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
775: <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>
776: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
777: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75 rillig 778: </dl></dd>
779: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
780: <dd><dl>
781: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
782: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
783: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
784: </dl></dd>
785: </dl></dd>
786: <dt><span class="chapter"><a href="#configuring">5. Configuring pkgsrc</a></span></dt>
787: <dd><dl>
788: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
789: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 790: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
1.88 wiz 791: <dd><dl>
1.89 rillig 792: <dt><span class="sect2"><a href="#selecting-the-compiler">5.3.1. Selecting the compiler</a></span></dt>
793: <dt><span class="sect2"><a href="#conf.cflags">5.3.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
794: <dt><span class="sect2"><a href="#conf.ldflags">5.3.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
1.88 wiz 795: </dl></dd>
1.78 rillig 796: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
797: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 798: </dl></dd>
799: <dt><span class="chapter"><a href="#binary">6. Creating binary packages</a></span></dt>
800: <dd><dl>
801: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
802: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
803: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
804: <dd><dl>
805: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
806: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
807: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
808: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
809: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
810: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
811: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
812: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
813: </dl></dd>
814: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
815: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
816: </dl></dd>
1.90 ! rillig 817: <dt><span class="chapter"><a href="#files">7. Directory layout of the installed files</a></span></dt>
! 818: <dd><dl>
! 819: <dt><span class="sect1"><a href="#files.localbase">7.1. File system layout in <code class="literal">${PREFIX}</code></a></span></dt>
! 820: <dt><span class="sect1"><a href="#files.varbase">7.2. File system layout in <code class="literal">${VARBASE}</code></a></span></dt>
! 821: </dl></dd>
! 822: <dt><span class="chapter"><a href="#faq">8. Frequently Asked Questions</a></span></dt>
1.75 rillig 823: <dd><dl>
1.90 ! rillig 824: <dt><span class="sect1"><a href="#mailing-list-pointers">8.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
! 825: <dt><span class="sect1"><a href="#pkgviews-docs">8.2. Where's the pkgviews documentation?</a></span></dt>
! 826: <dt><span class="sect1"><a href="#faq-pkgtools">8.3. Utilities for package management (pkgtools)</a></span></dt>
! 827: <dt><span class="sect1"><a href="#non-root-pkgsrc">8.4. How to use pkgsrc as non-root</a></span></dt>
! 828: <dt><span class="sect1"><a href="#resume-transfers">8.5. How to resume transfers when fetching distfiles?</a></span></dt>
! 829: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">8.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
! 830: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">8.7. How can I install/use X.org from pkgsrc?</a></span></dt>
! 831: <dt><span class="sect1"><a href="#fetch-behind-firewall">8.8. How to fetch files from behind a firewall</a></span></dt>
! 832: <dt><span class="sect1"><a href="#passive-ftp">8.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
! 833: <dt><span class="sect1"><a href="#fetching-all-distfiles">8.10. How to fetch all distfiles at once</a></span></dt>
! 834: <dt><span class="sect1"><a href="#tmac.andoc-missing">8.11. What does “<span class="quote">Don't know how to make
1.75 rillig 835: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
1.90 ! rillig 836: <dt><span class="sect1"><a href="#bsd.own.mk-missing">8.12. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</a></span></dt>
! 837: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">8.13. Using 'sudo' with pkgsrc</a></span></dt>
! 838: <dt><span class="sect1"><a href="#faq.conf">8.14. How do I change the location of configuration files?</a></span></dt>
! 839: <dt><span class="sect1"><a href="#audit-packages">8.15. Automated security checks</a></span></dt>
! 840: <dt><span class="sect1"><a href="#ufaq-cflags">8.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
! 841: <dt><span class="sect1"><a href="#ufaq-fail">8.17. A package does not build. What shall I do?</a></span></dt>
! 842: <dt><span class="sect1"><a href="#faq.rcs-conflicts">8.18. What does “<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>” mean?</a></span></dt>
! 843: <dt><span class="sect1"><a href="#too-much-time">8.19. I have a little time to kill. What shall I do?</a></span></dt>
1.75 rillig 844: </dl></dd>
845: </dl>
846: </div>
847: <div class="chapter" lang="en">
848: <div class="titlepage"><div><div><h2 class="title">
849: <a name="getting"></a>Chapter 2. Where to get pkgsrc and how to keep it up-to-date</h2></div></div></div>
850: <div class="toc">
851: <p><b>Table of Contents</b></p>
852: <dl>
853: <dt><span class="sect1"><a href="#getting-first">2.1. Getting pkgsrc for the first time</a></span></dt>
854: <dd><dl>
855: <dt><span class="sect2"><a href="#getting-via-tar">2.1.1. As tar file</a></span></dt>
856: <dt><span class="sect2"><a href="#getting-via-sup">2.1.2. Via SUP</a></span></dt>
857: <dt><span class="sect2"><a href="#getting-via-cvs">2.1.3. Via CVS</a></span></dt>
858: </dl></dd>
859: <dt><span class="sect1"><a href="#uptodate">2.2. Keeping pkgsrc up-to-date</a></span></dt>
860: <dd><dl>
861: <dt><span class="sect2"><a href="#uptodate-tar">2.2.1. Via tar files</a></span></dt>
862: <dt><span class="sect2"><a href="#uptodate-cvs">2.2.2. Via CVS</a></span></dt>
863: </dl></dd>
864: </dl>
865: </div>
866: <p>The most common location where pkgsrc is installed is
1.76 rillig 867: <code class="filename">/usr/pkgsrc</code> for the “<span class="quote">package
868: sources</span>” and <code class="filename">/usr/pkg</code> for the
1.75 rillig 869: installed binary packages. You are though free to install the
870: sources and binary packages wherever you want in your
871: filesystem, provided that both paths do not contain white-space
872: or other characters that are interpreted specially by the shell
873: and some other programs. A safe bet is to use only letters,
874: digits, underscores and dashes in the names.</p>
875: <div class="sect1" lang="en">
876: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
877: <a name="getting-first"></a>2.1. Getting pkgsrc for the first time</h2></div></div></div>
878: <p>Before you download any pkgsrc files, you should decide
879: whether you want the <span class="emphasis"><em>current</em></span> branch or the
880: <span class="emphasis"><em>stable</em></span> branch. The latter is forked on a
881: quarterly basis from the current branch and only gets modified
882: for security updates. The names of the stable branches are built
883: from the year and the quarter, for example
884: <code class="literal">2006Q1</code>.</p>
885: <p>The second step is to decide <span class="emphasis"><em>how</em></span> you
886: want to download pkgsrc. You can get it as a tar file, via SUP,
887: or via CVS. All three ways are described here.</p>
888: <div class="sect2" lang="en">
889: <div class="titlepage"><div><div><h3 class="title">
890: <a name="getting-via-tar"></a>2.1.1. As tar file</h3></div></div></div>
891: <p>The primary download location for all pkgsrc files is
892: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/</a>. There are a
893: number of subdirectories for different purposes, which are
1.76 rillig 894: described in detail in <a href="#ftp-layout" title="Appendix C. Directory layout of the pkgsrc FTP server">Appendix C, <i>Directory layout of the pkgsrc FTP server</i></a>.</p>
1.75 rillig 895: <p>The tar file for the current branch is in the directory
1.76 rillig 896: <code class="filename">current</code> and is called <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz" target="_top"><code class="filename">pkgsrc.tar.gz</code></a>.
1.75 rillig 897: It is autogenerated daily.</p>
898: <p>The tar file for the stable branch 2006Q1 is in the
1.76 rillig 899: directory <code class="filename">2006Q1</code> and is also called <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/2006Q1/pkgsrc.tar.gz" target="_top"><code class="filename">pkgsrc.tar.gz</code></a>.</p>
1.75 rillig 900: <p>After downloading the tar file, change to the directory
901: where you want to have pkgsrc. This is usually
1.76 rillig 902: <code class="filename">/usr</code>. Then, run <span><strong class="command">tar xfz
1.75 rillig 903: pkgsrc.tar.gz</strong></span> to extract the files.</p>
904: </div>
905: <div class="sect2" lang="en">
906: <div class="titlepage"><div><div><h3 class="title">
907: <a name="getting-via-sup"></a>2.1.2. Via SUP</h3></div></div></div>
908: <p>As an alternative to the tar file, you can get pkgsrc via
909: the Software Update Protocol, SUP. To do so, make sure your
910: supfile has a line
1.1 grant 911:
1.75 rillig 912: </p>
913: <pre class="programlisting">
1.51 rillig 914: release=pkgsrc
1.1 grant 915: </pre>
1.75 rillig 916: <p>
1.1 grant 917:
1.75 rillig 918: in it, see the examples in
1.76 rillig 919: <code class="filename">/usr/share/examples/supfiles</code>, and that the
920: <code class="filename">/usr/pkgsrc</code> directory exists. Then, simply
1.75 rillig 921: run <span><strong class="command">sup -v
922: <em class="replaceable"><code>/path/to/your/supfile</code></em></strong></span>.</p>
923: </div>
924: <div class="sect2" lang="en">
925: <div class="titlepage"><div><div><h3 class="title">
926: <a name="getting-via-cvs"></a>2.1.3. Via CVS</h3></div></div></div>
927: <p>To get pkgsrc via CVS, make sure you have <a href="http://netbsd.gw.com/cgi-bin/man-cgi?cvs+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">cvs</span>(1)</span></a>
928: installed. To do an initial (full) checkout of pkgsrc, you first
929: have to set some environment variables. For the C-Shell,
930: type:</p>
931: <pre class="screen">
932: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVSROOT anoncvs@anoncvs.NetBSD.org:/cvsroot</code></strong>
933: <code class="prompt">%</code> <strong class="userinput"><code>setenv CVS_RSH ssh</code></strong>
934: </pre>
935: <p>Or, the same for the bourne shell:</p>
936: <pre class="screen">
937: <code class="prompt">$</code> <strong class="userinput"><code>CVSROOT="anoncvs@anoncvs.NetBSD.org:/cvsroot"</code></strong>
938: <code class="prompt">$</code> <strong class="userinput"><code>CVS_RSH="ssh"</code></strong>
939: <code class="prompt">$</code> <strong class="userinput"><code>export CVSROOT CVS_RSH</code></strong>
940: </pre>
941: <p>Then, you change to the directory where you want to have
942: your copy of pkgsrc. In most cases this is
1.76 rillig 943: <code class="filename">/usr</code>. In that directory you run the
1.75 rillig 944: checkout command, which is <span><strong class="command">cvs -q checkout -P
945: pkgsrc</strong></span> for the current branch and <span><strong class="command">cvs -q
946: checkout -rpkgsrc-2006Q1 -P pkgsrc</strong></span> for the stable
947: branch. This command will create a directory called
1.76 rillig 948: <code class="filename">pkgsrc</code> with all the pkgsrc files in
1.75 rillig 949: it.</p>
950: </div>
951: </div>
952: <div class="sect1" lang="en">
953: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
954: <a name="uptodate"></a>2.2. Keeping pkgsrc up-to-date</h2></div></div></div>
955: <p>The preferred way to keep pkgsrc up-to-date is via CVS
956: (which also works if you have first installed it via a tar
957: file). It saves bandwidth and hard disk activity, compared to
958: downloading the tar file again.</p>
959: <div class="sect2" lang="en">
960: <div class="titlepage"><div><div><h3 class="title">
961: <a name="uptodate-tar"></a>2.2.1. Via tar files</h3></div></div></div>
962: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
963: <h3 class="title">Warning</h3>
1.77 rillig 964: <p>When updating from a tar file, you first need to
965: completely remove the old pkgsrc directory. Otherwise those
966: files that have been removed from pkgsrc in the mean time will
967: not be removed on your local disk, resulting in inconsistencies.
968: When removing the old files, any changes that you have done to
969: the pkgsrc files will be lost after updating. Therefore updating
970: via CVS is strongly recommended.</p>
1.75 rillig 971: </div>
1.82 rillig 972: <p>Note that by default the distfiles and the binary packages
973: are saved in the pkgsrc tree, so don't forget to rescue them
974: before updating. You can also configure pkgsrc to use other than
975: the default directories by setting the
976: <code class="varname">DISTDIR</code> and <code class="varname">PACKAGES</code>
977: variables. See <a href="#configuring" title="Chapter 5. Configuring pkgsrc">Chapter 5, <i>Configuring pkgsrc</i></a> for the details.</p>
1.75 rillig 978: <p>To update pkgsrc from a tar file, download the tar file as
979: explained above. Then, make sure that you have not made any
980: changes to the files in the pkgsrc directory. Remove the pkgsrc
981: directory and extract the new tar file. Done.</p>
982: </div>
983: <div class="sect2" lang="en">
984: <div class="titlepage"><div><div><h3 class="title">
985: <a name="uptodate-cvs"></a>2.2.2. Via CVS</h3></div></div></div>
986: <p>To update pkgsrc via CVS, make sure the environment
987: variable <code class="varname">CVS_RSH</code> is set as above. Then,
988: change to the pkgsrc directory and run <span><strong class="command">cvs -q update
1.77 rillig 989: -dP</strong></span>.</p>
1.75 rillig 990: <div class="sect3" lang="en">
991: <div class="titlepage"><div><div><h4 class="title">
992: <a name="uptodate-cvs-switch"></a>2.2.2.1. Switching between different pkgsrc branches</h4></div></div></div>
993: <p>When updating pkgsrc, the CVS program keeps track of the
994: branch you selected. But if you, for whatever reason, want to
995: switch from the stable branch to the current one, you can do it
996: by adding the option “<span class="quote">-A</span>” after the
997: “<span class="quote">update</span>” keyword. To switch from the current branch
998: back to the stable branch, add the
999: “<span class="quote">-rpkgsrc-2006Q1</span>” option.</p>
1000: </div>
1001: <div class="sect3" lang="en">
1002: <div class="titlepage"><div><div><h4 class="title">
1003: <a name="uptodate-cvs-changes"></a>2.2.2.2. What happens to my changes when updating?</h4></div></div></div>
1004: <p>When you update pkgsrc, the CVS program will only touch
1005: those files that are registered in the CVS repository. That
1006: means that any packages that you created on your own will stay
1007: unmodified. If you change files that are managed by CVS, later
1008: updates will try to merge your changes with those that have been
1009: done by others. See the CVS manual, chapter
1010: “<span class="quote">update</span>” for details.</p>
1011: </div>
1012: </div>
1013: </div>
1014: </div>
1015: <div class="chapter" lang="en">
1016: <div class="titlepage"><div><div><h2 class="title">
1017: <a name="platforms"></a>Chapter 3. Using pkgsrc on systems other than NetBSD</h2></div></div></div>
1018: <div class="toc">
1019: <p><b>Table of Contents</b></p>
1020: <dl>
1.82 rillig 1021: <dt><span class="sect1"><a href="#binarydist">3.1. Binary distribution</a></span></dt>
1022: <dt><span class="sect1"><a href="#bootstrapping-pkgsrc">3.2. Bootstrapping pkgsrc</a></span></dt>
1023: <dt><span class="sect1"><a href="#platform-specific-notes">3.3. Platform-specific notes</a></span></dt>
1024: <dd><dl>
1025: <dt><span class="sect2"><a href="#darwin">3.3.1. Darwin (Mac OS X)</a></span></dt>
1026: <dt><span class="sect2"><a href="#freebsd">3.3.2. FreeBSD</a></span></dt>
1027: <dt><span class="sect2"><a href="#interix">3.3.3. Interix</a></span></dt>
1028: <dt><span class="sect2"><a href="#irix">3.3.4. IRIX</a></span></dt>
1029: <dt><span class="sect2"><a href="#linux">3.3.5. Linux</a></span></dt>
1030: <dt><span class="sect2"><a href="#openbsd">3.3.6. OpenBSD</a></span></dt>
1031: <dt><span class="sect2"><a href="#solaris">3.3.7. Solaris</a></span></dt>
1.75 rillig 1032: </dl></dd>
1033: </dl>
1034: </div>
1035: <div class="sect1" lang="en">
1036: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82 rillig 1037: <a name="binarydist"></a>3.1. Binary distribution</h2></div></div></div>
1038: <p>
1039: We provide a bootstrap kit in both source and binary form for other
1040: platforms than NetBSD, consisting of the pkg administration tools and other
1041: tools required to use pkgsrc and build packages.
1042: </p>
1043: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1044: <h3 class="title">Note</h3>
1045: <p>
1046: Older binary snapshots are available in the
1047: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/archive/" target="_top">bootstrap-pkgsrc/archive</a>
1048: directory on ftp.NetBSD.org.</p>
1049: </div>
1050: <div class="table">
1051: <a name="binary-kits"></a><p class="title"><b>Table 3.1. Binary kits and available packages</b></p>
1.89 rillig 1052: <table summary="Binary kits and available packages" border="1">
1.82 rillig 1053: <colgroup>
1054: <col>
1055: <col>
1056: <col>
1057: <col>
1058: </colgroup>
1059: <thead><tr>
1060: <th>Platform</th>
1061: <th>Latest snapshot</th>
1062: <th>Binary kit</th>
1063: <th>Binary packages</th>
1064: </tr></thead>
1065: <tbody>
1066: <tr>
1067: <td class="osname">Darwin 5.5/powerpc (Mac OS X 10.1.5)</td>
1068: <td class="date">20021209</td>
1069: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-5.5-powerpc-20021209.tar.gz" target="_top">binary kit</a></td>
1070: <td class="binary-pkgs-url"> </td>
1071: </tr>
1072: <tr>
1073: <td class="osname">Darwin 6.6/powerpc (Mac OS X 10.2.6)</td>
1074: <td class="date">20030623</td>
1075: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-6.6-powerpc-20030623.tar.gz" target="_top">binary kit</a></td>
1076: <td class="binary-pkgs-url"> </td>
1077: </tr>
1078: <tr>
1079: <td class="osname">Darwin 7.6/powerpc (Mac OS X 10.3.6)</td>
1080: <td class="date">20041219</td>
1081: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-7.6.0-powerpc-20041219.tar.gz" target="_top">binary kit</a></td>
1082: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/Darwin-7.6/" target="_top">binary packages</a></td>
1083: </tr>
1084: <tr>
1085: <td class="osname">Darwin 7.8/powerpc (Mac OS X 10.3.8)</td>
1086: <td class="date">20050320</td>
1087: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-7.8.0-powerpc-20050320.tar.gz" target="_top">binary kit</a></td>
1088: <td class="binary-pkgs-url"> </td>
1089: </tr>
1090: <tr>
1091: <td class="osname">Darwin 8.1/powerpc (Mac OS X 10.4.1)</td>
1092: <td class="date">20050625</td>
1093: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Darwin-8.1.0-powerpc-20050625.tar.gz" target="_top">binary kit</a></td>
1094: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/Darwin-8.1/powerpc/current/" target="_top">binary packages</a></td>
1095: </tr>
1096: <tr>
1097: <td class="osname">Debian GNU Linux/i386</td>
1098: <td class="date">20031023</td>
1099: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.4.22-debian-i386-20031023.tar.gz" target="_top">binary kit</a></td>
1100: <td class="binary-pkgs-url"> </td>
1101: </tr>
1102: <tr>
1103: <td class="osname">Fedora Core 2 Linux/i386</td>
1104: <td class="date">20050618</td>
1105: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.6.10-i386-fc2-20050618.tar.gz" target="_top">binary kit</a></td>
1106: <td class="binary-pkgs-url"> </td>
1107: </tr>
1108: <tr>
1109: <td class="osname">Fedora Core 4 Linux/i386</td>
1110: <td class="date">20060105</td>
1111: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.6.11-i386-fc4-20060105.tar.gz" target="_top">binary kit</a></td>
1112: <td class="binary-pkgs-url"> </td>
1113: </tr>
1114: <tr>
1115: <td class="osname">FreeBSD 3.5/i386</td>
1116: <td class="date">20030411</td>
1117: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-3.5-STABLE-i386-20030411.tar.gz" target="_top">binary kit</a></td>
1118: <td class="binary-pkgs-url"> </td>
1119: </tr>
1120: <tr>
1121: <td class="osname">FreeBSD 4.7/i386</td>
1122: <td class="date">20021211</td>
1123: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-4.7-RELEASE-i386-20021211.tar.gz" target="_top">binary kit</a></td>
1124: <td class="binary-pkgs-url"> </td>
1125: </tr>
1126: <tr>
1127: <td class="osname">FreeBSD 5.0/i386</td>
1128: <td class="date">20030411</td>
1129: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-5.0-RELEASE-i386-20030411.tar.gz" target="_top">binary kit</a></td>
1130: <td class="binary-pkgs-url"> </td>
1131: </tr>
1132: <tr>
1133: <td class="osname">FreeBSD 5.1/i386</td>
1134: <td class="date">20030630</td>
1135: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-5.1-RELEASE-i386-20030630.tar.gz" target="_top">binary kit</a></td>
1136: <td class="binary-pkgs-url"> </td>
1137: </tr>
1138: <tr>
1139: <td class="osname">FreeBSD 5.2.1/i386</td>
1140: <td class="date">20040227</td>
1141: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-5.2.1-RELEASE-i386-20040227.tar.gz" target="_top">binary kit</a></td>
1142: <td class="binary-pkgs-url"> </td>
1143: </tr>
1144: <tr>
1145: <td class="osname">FreeBSD 5.3/i386</td>
1146: <td class="date">20050119</td>
1147: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-FreeBSD-5.3-RELEASE-i386-20050119.tar" target="_top">binary kit</a></td>
1148: <td class="binary-pkgs-url"> </td>
1149: </tr>
1150: <tr>
1151: <td class="osname">Interix 3.5</td>
1152: <td class="date">20051010</td>
1153: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Interix-3.5-i386-20051010.tar.gz" target="_top">binary kit</a></td>
1154: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/Interix-3.5/i386/current/" target="_top">binary packages</a></td>
1155: </tr>
1156: <tr>
1157: <td class="osname">IRIX 6.5 n32-bit ABI</td>
1158: <td class="date">20040911</td>
1159: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-IRIX-6.5-mips-20040911.tar.gz" target="_top">binary kit</a></td>
1160: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/n32/" target="_top">binary packages</a></td>
1161: </tr>
1162: <tr>
1163: <td class="osname">IRIX 6.5 64-bit ABI</td>
1164: <td class="date">20040912</td>
1165: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-IRIX64-6.5-mips-20040912.tar.gz" target="_top">binary kit</a></td>
1166: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/IRIX-6.5/64/" target="_top">binary packages</a></td>
1167: </tr>
1168: <tr>
1169: <td class="osname">OpenBSD 3.2/i386</td>
1170: <td class="date">20030420</td>
1171: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-OpenBSD-3.2-i386-20030420.tar.gz" target="_top">binary kit</a></td>
1172: <td class="binary-pkgs-url"> </td>
1173: </tr>
1174: <tr>
1175: <td class="osname">OpenBSD 3.3/i386</td>
1176: <td class="date">20030503</td>
1177: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-OpenBSD-3.3-i386-20030503.tar.gz" target="_top">binary kit</a></td>
1178: <td class="binary-pkgs-url"> </td>
1179: </tr>
1180: <tr>
1181: <td class="osname">OpenBSD 3.5/i386</td>
1182: <td class="date">20040507</td>
1183: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-OpenBSD-3.5-i386-20040703.tar.gz" target="_top">binary kit</a></td>
1184: <td class="binary-pkgs-url"> </td>
1185: </tr>
1186: <tr>
1187: <td class="osname">Slackware Linux 8.1/i386</td>
1188: <td class="date">20030417</td>
1189: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.4.18-slackware-20030417.tar.gz" target="_top">binary kit</a></td>
1190: <td class="binary-pkgs-url"> </td>
1191: </tr>
1192: <tr>
1193: <td class="osname">Slackware Linux 9/i386</td>
1194: <td class="date">20031023</td>
1195: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-Linux-2.4.22-i386-slackware9-20040703.tar.gz" target="_top">binary kit</a></td>
1196: <td class="binary-pkgs-url"> </td>
1197: </tr>
1198: <tr>
1199: <td class="osname">Solaris 8/sparc</td>
1200: <td class="date">20050220</td>
1201: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-SunOS-5.8-sparc-20050220.tar.gz" target="_top">binary kit</a></td>
1202: <td class="binary-pkgs-url"> </td>
1203: </tr>
1204: <tr>
1205: <td class="osname">Solaris 8/i386</td>
1206: <td class="date">20050220</td>
1207: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-SunOS-5.8-i386-20050220.tar.gz" target="_top">binary kit</a></td>
1208: <td class="binary-pkgs-url"> </td>
1209: </tr>
1210: <tr>
1211: <td class="osname">Solaris 9/sparc</td>
1212: <td class="date">20041208</td>
1213: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-SunOS-5.9-sparc-20041208.tar.gz" target="_top">binary kit</a></td>
1214: <td class="binary-pkgs-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/SunOS-5.9/sparc/" target="_top">binary packages</a></td>
1215: </tr>
1216: <tr>
1217: <td class="osname">Solaris 9/i386</td>
1218: <td class="date">20030411</td>
1219: <td class="kit-url"><a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/bootstrap-pkgsrc-SunOS-5.9-i386-20030411.tar.gz" target="_top">binary kit</a></td>
1220: <td class="binary-pkgs-url"> </td>
1221: </tr>
1222: </tbody>
1.89 rillig 1223: </table>
1.82 rillig 1224: </div>
1.89 rillig 1225: <p>
1.82 rillig 1226: Simply download the binary kit for your platform, and extract it into
1227: <code class="filename">/</code> e.g.
1228: </p>
1229: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
1230: <code class="prompt">#</code> <strong class="userinput"><code>gzip -c -d /tmp/bootstrap-pkgsrc-SunOS-5.9-sparc-20031023.tar.gz \
1231: | tar -xpf -</code></strong></pre>
1232: <p>
1233: Of course, as with any binary distributions, you should verify the
1234: checksum against the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/SUM" target="_top">SUM</a>
1235: or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/bootstrap-pkgsrc/CKSUM" target="_top">CKSUM</a>
1236: file and inspect the contents before extracting it.
1237: </p>
1238: </div>
1239: <div class="sect1" lang="en">
1240: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1241: <a name="bootstrapping-pkgsrc"></a>3.2. Bootstrapping pkgsrc</h2></div></div></div>
1242: <p>Installing the bootstrap kit from source should be as simple as:</p>
1.75 rillig 1243: <pre class="screen">
1244: <code class="prompt">#</code> <strong class="userinput"><code>env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout pkgsrc</code></strong>
1245: <code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1.87 wiz 1246: <code class="prompt">#</code> <strong class="userinput"><code>./bootstrap</code></strong>
1247: </pre>
1.75 rillig 1248: <p>See <a href="#getting" title="Chapter 2. Where to get pkgsrc and how to keep it up-to-date">Chapter 2, <i>Where to get pkgsrc and how to keep it up-to-date</i></a> for other ways to get
1.87 wiz 1249: pkgsrc before bootstrapping. The given
1250: <span><strong class="command">bootstrap</strong></span> command will use the defaults of
1251: <code class="filename">/usr/pkg</code> for the
1252: <span class="emphasis"><em>prefix</em></span> where programs will be installed in,
1253: and <code class="filename">/var/db/pkg</code> for the package database
1254: directory where pkgsrc will do its internal bookkeeping.
1255: However, these can also be set using command-line
1256: arguments.</p>
1.75 rillig 1257: <p>Binary packages for the pkgsrc tools and an initial set of packages is
1.87 wiz 1258: available for supported platforms. An up-to-date list of these can be
1259: found on <a href="http://www.pkgsrc.org/" target="_top">www.pkgsrc.org</a>.
1260: Note that this only works for privileged builds that install
1261: into <code class="filename">/usr/pkg</code>.</p>
1.75 rillig 1262: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1263: <h3 class="title">Note</h3>
1264: <p>The bootstrap installs a <span><strong class="command">bmake</strong></span> tool.
1.87 wiz 1265: Use this <span><strong class="command">bmake</strong></span> when building via pkgsrc.
1266: For examples in this guide, use <span><strong class="command">bmake</strong></span>
1267: instead of “<span class="quote">make</span>”.</p>
1.75 rillig 1268: </div>
1269: </div>
1270: <div class="sect1" lang="en">
1271: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.82 rillig 1272: <a name="platform-specific-notes"></a>3.3. Platform-specific notes</h2></div></div></div>
1.75 rillig 1273: <p>Here are some platform-specific notes you should be aware of.</p>
1274: <div class="sect2" lang="en">
1275: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1276: <a name="darwin"></a>3.3.1. Darwin (Mac OS X)</h3></div></div></div>
1.85 jmmv 1277: <p>Darwin 5.x and up are supported. There are two methods of using
1.82 rillig 1278: pkgsrc on Mac OS X, by using a <a href="#platform.osx-image" title="3.3.1.1. Using a disk image">disk
1.89 rillig 1279: image</a>, or a <a href="#platform.osx-part" title="3.3.1.2. Using a UFS or HFSX partition">UFS or HFSX
1.75 rillig 1280: partition</a>.</p>
1281: <p>Before you start, you will need to download and install the Mac OS X Developer
1.87 wiz 1282: Tools from Apple's Developer Connection. See <a href="http://developer.apple.com/macosx/" target="_top">http://developer.apple.com/macosx/</a>
1283: for details. Also, make sure you install X11 for Mac OS X and the X11 SDK
1284: from <a href="http://www.apple.com/macosx/x11/download/" target="_top">http://www.apple.com/macosx/x11/download/</a>
1285: if you intend to build packages that use the X11 Window System.</p>
1.89 rillig 1286: <p>If you already have a UFS or HFSX partition, or have a spare partition
1287: that you can format as UFS or HFSX, it is recommended to use that instead of
1.87 wiz 1288: the disk image. It'll be somewhat faster and will mount automatically
1289: at boot time, where you must manually mount a disk image.</p>
1.75 rillig 1290: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1291: <h3 class="title">Note</h3>
1.85 jmmv 1292: <p>You cannot use an ordinary HFS+ file system for pkgsrc, because pkgsrc currently
1.89 rillig 1293: requires the file system to be case-sensitive. You can, however, use a case-sensitive HFS+ (aka HFSX) file system as found in Darwin 7.0 and newer.</p>
1.75 rillig 1294: </div>
1295: <div class="sect3" lang="en">
1296: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1297: <a name="platform.osx-image"></a>3.3.1.1. Using a disk image</h4></div></div></div>
1.75 rillig 1298: <p>Create the disk image:</p>
1299: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd pkgsrc/bootstrap</code></strong>
1.85 jmmv 1300: <code class="prompt">#</code> <strong class="userinput"><code>./darwindiskimage create ~/Documents/NetBSD 512</code></strong> # megabytes - season to taste
1301: <code class="prompt">#</code> <strong class="userinput"><code>./darwindiskimage mount ~/Documents/NetBSD</code></strong>
1.75 rillig 1302: <code class="prompt">#</code> <strong class="userinput"><code>sudo chown `id -u`:`id -g` /Volumes/NetBSD</code></strong></pre>
1.85 jmmv 1303: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1304: <h3 class="title">Note</h3>
1.89 rillig 1305: <p>darwindiskimage will mount the filesystem nosuid, which will cause problems for packages that depend on setgid. In the case of UFS, it will also mount the filesystem asynchronous, which is somewhat dangerous according to the mount(8) man page. In the case of HFSX, it will disable journalling.</p>
1.85 jmmv 1306: </div>
1.89 rillig 1307: <p>Allow suid:</p>
1308: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sudo mount -u -o suid /Volumes/NetBSD</code></strong></pre>
1.75 rillig 1309: </div>
1310: <div class="sect3" lang="en">
1311: <div class="titlepage"><div><div><h4 class="title">
1.89 rillig 1312: <a name="platform.osx-part"></a>3.3.1.2. Using a UFS or HFSX partition</h4></div></div></div>
1.76 rillig 1313: <p>By default, <code class="filename">/usr</code> will be on your root file
1.87 wiz 1314: system, normally HFS+. It is possible to use the default
1315: <span class="emphasis"><em>prefix</em></span> of <code class="filename">/usr/pkg</code>
1316: by symlinking <code class="filename">/usr/pkg</code> to a directory on a UFS
1.89 rillig 1317: or HFSX file system. Obviously, another symlink is required if you want to
1.87 wiz 1318: place the package database directory outside the
1319: <span class="emphasis"><em>prefix</em></span>. e.g.</p>
1.75 rillig 1320: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>./bootstrap --pkgdbdir /usr/pkg/pkgdb</code></strong></pre>
1321: <p>If you created your partitions at the time of installing Mac OS X
1.89 rillig 1322: and formatted the target partition as UFS or HFSX, it should automatically
1.87 wiz 1323: mount on <code class="filename">/Volumes/<volume name></code> when the
1.89 rillig 1324: machine boots. If you are (re)formatting a partition as UFS or HFSX, you need
1.87 wiz 1325: to ensure that the partition map correctly reflects
1.89 rillig 1326: “<span class="quote">Apple_UFS</span>” or “<span class="quote">Apple_HFSX</span>” and not “<span class="quote">Apple_HFS</span>”.</p>
1.75 rillig 1327: <p>The problem is that none of the disk tools will let you touch a
1.87 wiz 1328: disk that is booted from. You can unmount the partition, but even if
1329: you newfs it, the partition type will be incorrect and the
1330: automounter won't mount it. It can be mounted manually, but it won't
1331: appear in Finder.</p>
1.75 rillig 1332: <p>You'll need to boot off of the OS X Installation (User) CD. When
1.87 wiz 1333: the Installation program starts, go up to the menu and select Disk
1334: Utility. Now, you will be able to select the partition you want
1.89 rillig 1335: to be UFS or HFSX, and Format it Apple UFS or HFSX. Quit the Disk Utility, quit the
1336: installer which will reboot your machine. The new UFS or HFSX file system
1.87 wiz 1337: will appear in Finder.</p>
1.75 rillig 1338: <p>Be aware that the permissions on the new file system will be writable
1.87 wiz 1339: by root only.</p>
1.75 rillig 1340: <p>This note is as of 10.2 (Jaguar) and applies to earlier versions.
1.87 wiz 1341: Hopefully Apple will fix Disk Utility in 10.3 (Panther).</p>
1.75 rillig 1342: </div>
1343: </div>
1344: <div class="sect2" lang="en">
1345: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1346: <a name="freebsd"></a>3.3.2. FreeBSD</h3></div></div></div>
1.87 wiz 1347: <p>FreeBSD 4.7 and 5.0 have been tested and are supported,
1348: other versions may work.</p>
1.75 rillig 1349: <p>Care should be taken so that the tools that this kit installs do not conflict
1.87 wiz 1350: with the FreeBSD userland tools. There are several steps:</p>
1.75 rillig 1351: <div class="orderedlist"><ol type="1">
1352: <li><p>FreeBSD stores its ports pkg database in
1.87 wiz 1353: <code class="filename">/var/db/pkg</code>. It is therefore
1354: recommended that you choose a different location (e.g.
1355: <code class="filename">/usr/pkgdb</code>) by
1356: using the --pkgdbdir option to the bootstrap script.</p></li>
1.75 rillig 1357: <li>
1358: <p>If you do not intend to use the FreeBSD ports tools, it's probably a
1.87 wiz 1359: good idea to move them out of the way to avoid confusion, e.g.</p>
1360: <pre class="screen">
1361: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1.75 rillig 1362: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1363: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1364: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1.87 wiz 1365: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong>
1366: </pre>
1.75 rillig 1367: </li>
1.76 rillig 1368: <li><p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1.87 wiz 1369: <code class="filename">/etc/mk.conf.example</code> file
1370: when you use the bootstrap script.</p></li>
1.75 rillig 1371: </ol></div>
1372: </div>
1373: <div class="sect2" lang="en">
1374: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1375: <a name="interix"></a>3.3.3. Interix</h3></div></div></div>
1.75 rillig 1376: <p>Interix is a POSIX-compatible subsystem for the Windows NT kernel,
1.87 wiz 1377: providing a Unix-like environment with a tighter kernel integration than
1378: available with Cygwin. It is part of the Windows Services for Unix
1379: package, available for free for any licensed copy of Windows 2000, XP
1380: (not including XP Home), or 2003. SFU can be downloaded from <a href="http://www.microsoft.com/windows/sfu/" target="_top">http://www.microsoft.com/windows/sfu/</a>.</p>
1.75 rillig 1381: <p>Services for Unix 3.5, current as of this writing, has been tested. 3.0
1.87 wiz 1382: or 3.1 may work, but are not officially supported. (The main difference
1383: in 3.0/3.1 is lack of pthreads.)</p>
1.75 rillig 1384: <div class="sect3" lang="en">
1385: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1386: <a name="platform.interix-sfu-install"></a>3.3.3.1. When installing Interix/SFU</h4></div></div></div>
1.75 rillig 1387: <p>At an absolute minimum, the following packages must be installed from
1.87 wiz 1388: the Windows Services for Unix 3.5 distribution in order to use pkgsrc:</p>
1.75 rillig 1389: <div class="itemizedlist"><ul type="disc">
1390: <li><p>Utilities -> Base Utilities</p></li>
1391: <li><p>Interix GNU Components -> (all)</p></li>
1392: <li><p>Remote Connectivity</p></li>
1393: <li><p>Interix SDK</p></li>
1394: </ul></div>
1395: <p>When using pkgsrc on Interix, DO NOT install the Utilities subcomponent
1.87 wiz 1396: "UNIX Perl". That is Perl 5.6 without shared module support, installed to
1397: /usr/local, and will only cause confusion. Instead, install Perl 5.8 from
1398: pkgsrc (or from a binary package).</p>
1.75 rillig 1399: <p>The Remote Connectivity subcomponent "Windows Remote Shell Service" does
1.87 wiz 1400: not need to be installed, but Remote Connectivity itself should be
1401: installed in order to have a working inetd.</p>
1.75 rillig 1402: <p>During installation you may be asked whether to enable setuid
1.87 wiz 1403: behavior for Interix programs, and whether to make pathnames default to
1404: case-sensitive. Setuid should be enabled, and case-sensitivity MUST be
1405: enabled. (Without case-sensitivity, a large number of packages including
1406: perl will not build.)</p>
1.75 rillig 1407: <p>NOTE: Newer Windows service packs change the way binary execution
1.87 wiz 1408: works (via the Data Execution Prevention feature). In order to use
1409: pkgsrc and other gcc-compiled binaries reliably, a hotfix containing
1410: POSIX.EXE, PSXDLL.DLL, PSXRUN.EXE, and PSXSS.EXE (899522 or newer)
1411: must be installed. Hotfixes are available from Microsoft through a
1412: support contract; however, a NetBSD developer has made most Interix
1413: hotfixes available for personal use from <a href="http://www.duh.org/interix/hotfixes.php" target="_top">http://www.duh.org/interix/hotfixes.php</a>.</p>
1.75 rillig 1414: </div>
1415: <div class="sect3" lang="en">
1416: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1417: <a name="platform.interix-sfu-postinstall"></a>3.3.3.2. What to do if Interix/SFU is already installed</h4></div></div></div>
1.75 rillig 1418: <p>If SFU is already installed and you wish to alter these settings to work
1.87 wiz 1419: with pkgsrc, note the following things.</p>
1.75 rillig 1420: <div class="itemizedlist"><ul type="disc">
1421: <li><p>To uninstall UNIX Perl, use Add/Remove Programs, select Microsoft
1.87 wiz 1422: Windows Services for UNIX, then click Change. In the installer, choose
1423: Add or Remove, then uncheck Utilities->UNIX Perl.</p></li>
1.75 rillig 1424: <li>
1425: <p>To enable case-sensitivity for the file system, run REGEDIT.EXE, and
1.87 wiz 1426: change the following registry key:</p>
1.75 rillig 1427: <p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel</p>
1428: <p>Set the DWORD value "obcaseinsensitive" to 0; then reboot.</p>
1429: </li>
1430: <li>
1431: <p>To enable setuid binaries (optional), run REGEDIT.EXE, and change the
1.87 wiz 1432: following registry key:</p>
1.75 rillig 1433: <p>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Services for UNIX</p>
1434: <p>Set the DWORD value "EnableSetuidBinaries" to 1; then reboot.</p>
1435: </li>
1436: </ul></div>
1437: </div>
1438: <div class="sect3" lang="en">
1439: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1440: <a name="platform.interix-notes"></a>3.3.3.3. Important notes for using pkgsrc</h4></div></div></div>
1.75 rillig 1441: <p>The package manager (either the pkgsrc "su" user, or the user
1.87 wiz 1442: running "pkg_add") must be a member of the local Administrators
1443: group. Such a user must also be used to run the bootstrap. This is
1444: slightly relaxed from the normal pkgsrc requirement of "root".</p>
1.75 rillig 1445: <p>The package manager should use a umask of 002. "make install" will
1.87 wiz 1446: automatically complain if this is not the case. This ensures that
1447: directories written in /var/db/pkg are Administrators-group writeable.</p>
1.75 rillig 1448: <p>The popular Interix binary packages from http://www.interopsystems.com/
1.87 wiz 1449: use an older version of pkgsrc's pkg_* tools. Ideally, these should
1450: NOT be used in conjunction with pkgsrc. If you choose to use them at
1451: the same time as the pkgsrc packages, ensure that you use the proper
1452: pkg_* tools for each type of binary package.</p>
1.75 rillig 1453: <p>The TERM setting used for DOS-type console windows (including those
1.87 wiz 1454: invoked by the csh and ksh startup shortcuts) is "interix". Most systems
1455: don't have a termcap/terminfo entry for it, but the following .termcap
1456: entry provides adequate emulation in most cases:</p>
1.75 rillig 1457: <pre class="programlisting">
1.87 wiz 1458: interix:kP=\E[S:kN=\E[T:kH=\E[U:dc@:DC@:tc=pcansi:
1459: </pre>
1.75 rillig 1460: </div>
1461: <div class="sect3" lang="en">
1462: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1463: <a name="platform.interix-limits"></a>3.3.3.4. Limitations of the Interix platform</h4></div></div></div>
1.75 rillig 1464: <p>Though Interix suffices as a familiar and flexible substitute
1.87 wiz 1465: for a full Unix-like platform, it has some drawbacks that should
1466: be noted for those desiring to make the most of Interix.</p>
1.75 rillig 1467: <div class="itemizedlist"><ul type="disc">
1468: <li>
1469: <p><span class="strong"><strong>X11:</strong></span></p>
1470: <p>Interix comes with the standard set of X11R6 client libraries,
1.87 wiz 1471: and can run X11 based applications, but it does
1472: <span class="emphasis"><em>not</em></span> come with an X server. Some options are
1473: <a href="http://www.starnet.com/products/xwin32/" target="_top">StarNet X-Win32</a>,
1474: <a href="http://connectivity.hummingbird.com/products/nc/exceed/" target="_top">Hummingbird Exceed</a>
1475: (available in a trimmed version for Interix from Interop Systems as the
1476: <a href="http://www.interopsystems.com/InteropXserver.htm" target="_top">Interop X Server</a>),
1477: and the free X11 server included with
1478: <a href="http://x.cygwin.com/" target="_top">Cygwin</a>.</p>
1.75 rillig 1479: <p>Also, StarNet Communications has graciously provided a free
1.87 wiz 1480: version of their X-Win32 product that accepts connections only
1481: from localhost:
1482: <a href="http://www.starnet.com/xwin32LX/get_xwin32LX.htm" target="_top">X-Win32 LX</a>,
1483: recommended by the maintainer of Interix pkgsrc support.</p>
1.75 rillig 1484: </li>
1485: <li>
1486: <p><span class="strong"><strong>X11 acceleration:</strong></span></p>
1487: <p>Because Interix runs in a completely different NT subsystem from
1.87 wiz 1488: Win32 applications, it does not currently support various X11
1489: protocol extensions for acceleration (such as MIT-SHM or DGA).
1490: Most interactive applications to a local X server will run
1491: reasonably fast, but full motion video and other graphics
1492: intensive applications may require a faster-than-expected CPU.</p>
1.75 rillig 1493: </li>
1494: <li>
1495: <p><span class="strong"><strong>Audio:</strong></span></p>
1496: <p>Interix has no native support for audio output. For audio
1.87 wiz 1497: support, pkgsrc uses the <span><strong class="command">esound</strong></span> client/server
1498: audio system on Interix. Unlike on most platforms, the
1499: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/audio/esound/README.html" target="_top"><code class="filename">audio/esound</code></a> package does
1500: <span class="emphasis"><em>not</em></span> contain the <span><strong class="command">esd</strong></span>
1501: server component. To output audio via an Interix host, the
1502: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/emulators/cygwin_esound/README.html" target="_top"><code class="filename">emulators/cygwin_esound</code></a> package
1503: must also be installed.</p>
1.75 rillig 1504: </li>
1505: <li>
1506: <p><span class="strong"><strong>CD/DVDs, USB, and SCSI:</strong></span></p>
1507: <p>Direct device access is not currently supported in Interix, so it
1.87 wiz 1508: is not currently possible to access CD/DVD drives, USB devices,
1509: or SCSI devices through non-filesystem means. Among other things,
1510: this makes it impossible to use Interix directly for CD/DVD
1511: burning.</p>
1.75 rillig 1512: </li>
1513: <li>
1514: <p><span class="strong"><strong>Tape drives:</strong></span></p>
1515: <p>Due to the same limitations as for CD-ROMs and SCSI devices, tape
1.87 wiz 1516: drives are also not directly accessible in Interix. However,
1517: support is in work to make tape drive access possible by using
1518: Cygwin as a bridge (similarly to audio bridged via Cygwin's
1519: esound server).</p>
1.75 rillig 1520: </li>
1521: </ul></div>
1522: </div>
1523: <div class="sect3" lang="en">
1524: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1525: <a name="platform.interix-knownissues"></a>3.3.3.5. Known issues for pkgsrc on Interix</h4></div></div></div>
1.75 rillig 1526: <p>It is not necessary, in general, to have a "root" user on the
1.87 wiz 1527: Windows system; any member of the local Administrators group will
1528: suffice. However, some packages currently assume that the user
1529: named "root" is the privileged user. To accommodate these, you
1530: may create such a user; make sure it is in the local group
1531: Administrators (or your language equivalent).</p>
1532: <p><span><strong class="command">pkg_add</strong></span> creates directories of mode
1533: 0755, not 0775, in <code class="filename">$PKG_DBDIR</code>. For the
1534: time being, install packages as the local Administrator (or
1535: your language equivalent), or run the following command after
1536: installing a package to work around the issue:</p>
1.75 rillig 1537: <pre class="screen">
1.87 wiz 1538: <code class="prompt">#</code> <strong class="userinput"><code>chmod -R g+w $PKG_DBDIR</code></strong>
1539: </pre>
1.75 rillig 1540: </div>
1541: </div>
1542: <div class="sect2" lang="en">
1543: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1544: <a name="irix"></a>3.3.4. IRIX</h3></div></div></div>
1.75 rillig 1545: <p>You will need a working C compiler, either gcc or SGI's MIPS and MIPSpro
1.87 wiz 1546: compiler (cc/c89). Please set the <code class="varname">CC</code> environment variable
1547: according to your preference. If you do not have a license for the MIPSpro
1548: compiler suite, you can download a gcc tardist file from <a href="http://freeware.sgi.com/" target="_top">http://freeware.sgi.com/</a>.</p>
1.75 rillig 1549: <p>Please note that you will need IRIX 6.5.17 or higher, as this is the earliest
1.87 wiz 1550: version of IRIX providing support for <a href="http://netbsd.gw.com/cgi-bin/man-cgi?if_indextoname+3+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">if_indextoname</span>(3)</span></a>, <a href="http://netbsd.gw.com/cgi-bin/man-cgi?if_nametoindex+3+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">if_nametoindex</span>(3)</span></a>,
1551: etc.</p>
1.86 schwarz 1552: <p>At this point in time, pkgsrc only supports one ABI at a time. That is, you cannot
1.75 rillig 1553: switch between the old 32-bit ABI, the new 32-bit ABI and the 64-bit ABI. If
1554: you start out using "abi=n32", that's what all your packages will be built
1555: with.</p>
1556: <p>Therefore, please make sure that you have no conflicting
1.87 wiz 1557: <code class="varname">CFLAGS</code> in your environment or the
1558: <code class="filename">/etc/mk.conf</code>. Particularly, make sure that you do not
1559: try to link n32 object files with lib64 or vice versa. Check your
1560: <code class="filename">/etc/compiler.defaults</code>!</p>
1.75 rillig 1561: <p>If you have the actual pkgsrc tree mounted via NFS from a different host,
1.87 wiz 1562: please make sure to set <code class="varname">WRKOBJDIR</code> to a local directory,
1563: as it appears that IRIX linker occasionally runs into issues when trying to
1564: link over a network-mounted file system.</p>
1.75 rillig 1565: <p>The bootstrapping process should set all the right options for programs such
1.87 wiz 1566: as imake(1), but you may want to set some options depending on your local
1567: setup. Please see <code class="filename">pkgsrc/mk/defaults/mk.conf</code> and, of
1568: course, your compiler's man pages for details.</p>
1.75 rillig 1569: <p>If you are using SGI's MIPSPro compiler, please set
1.1 grant 1570:
1.87 wiz 1571: </p>
1.75 rillig 1572: <pre class="programlisting">
1.87 wiz 1573: PKGSRC_COMPILER= mipspro
1574: </pre>
1.75 rillig 1575: <p>
1.1 grant 1576:
1.87 wiz 1577: in <code class="filename">/etc/mk.conf</code>. Otherwise, pkgsrc will assume you
1578: are using gcc and may end up passing invalid flags to the compiler. Note that
1579: bootstrap should create an appropriate <code class="filename">mk.conf.example</code> by
1580: default.</p>
1.75 rillig 1581: <p>If you have both the MIPSPro compiler chain installed as well as gcc,
1.87 wiz 1582: but want to make sure that MIPRPro is used, please set your <code class="varname">PATH</code>
1583: to <span class="emphasis"><em>not</em></span> include the location of gcc (often
1584: <code class="filename">/usr/freeware/bin</code>), and (important) pass the
1585: '--preserve-path' flag.</p>
1.75 rillig 1586: </div>
1587: <div class="sect2" lang="en">
1588: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1589: <a name="linux"></a>3.3.5. Linux</h3></div></div></div>
1.87 wiz 1590: <p>Some versions of Linux (for example Debian GNU/Linux) need
1591: either libtermcap or libcurses (libncurses). Installing the
1592: distributions libncurses-dev package (or equivalent) should fix
1593: the problem.</p>
1594: <p>pkgsrc supports both gcc (GNU Compiler Collection) and icc
1595: (Intel C++ Compiler). gcc is the default. icc 8.0 and 8.1 on
1596: i386 have been tested.</p>
1.75 rillig 1597: <p>To bootstrap using icc, assuming the default icc installation
1.87 wiz 1598: directory:</p>
1.75 rillig 1599: <pre class="programlisting">
1.87 wiz 1600: env CC=/opt/intel_cc_80/bin/icc LDFLAGS=-static-libcxa \
1601: ac_cv___attribute__=yes ./bootstrap
1602: </pre>
1.75 rillig 1603: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1604: <h3 class="title">Note</h3>
1605: <p>icc 8.1 needs the `-i-static' argument instead of -static-libcxa.</p>
1606: </div>
1607: <p>icc supports __attribute__, but the GNU configure test uses a nested
1.87 wiz 1608: function, which icc does not support. #undef'ing __attribute__ has the
1609: unfortunate side-effect of breaking many of the Linux header files, which
1610: cannot be compiled properly without __attribute__. The test must be
1611: overridden so that __attribute__ is assumed supported by the
1612: compiler.</p>
1.75 rillig 1613: <p>After bootstrapping, you should set <code class="varname">PKGSRC_COMPILER</code>
1.87 wiz 1614: in <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1615: <pre class="programlisting">
1.87 wiz 1616: PKGSRC_COMPILER= icc
1617: </pre>
1.75 rillig 1618: <p>The default installation directory for icc is
1.87 wiz 1619: <code class="filename">/opt/intel_cc_80</code>, which
1620: is also the pkgsrc default. If you have installed it into a different
1621: directory, set <code class="varname">ICCBASE</code> in
1622: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 1623: <pre class="programlisting">
1.87 wiz 1624: ICCBASE= /opt/icc
1625: </pre>
1.75 rillig 1626: <p>pkgsrc uses the static linking method of the runtime libraries
1.87 wiz 1627: provided by icc, so binaries can be run on other systems which do not
1628: have the shared libraries installed.</p>
1629: <p>Libtool, however, extracts a list of libraries from the
1630: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ld+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ld</span>(1)</span></a> command run when linking a C++ shared library and
1631: records it, throwing away the -Bstatic and -Bdynamic options
1632: interspersed between the libraries. This means that
1633: libtool-linked C++ shared libraries will have a runtime
1634: dependency on the icc libraries until this is fixed in
1635: libtool.</p>
1.75 rillig 1636: </div>
1637: <div class="sect2" lang="en">
1638: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1639: <a name="openbsd"></a>3.3.6. OpenBSD</h3></div></div></div>
1.75 rillig 1640: <p>OpenBSD 3.0 and 3.2 are tested and supported.</p>
1641: <p>Care should be taken so that the tools that this kit installs do not conflict
1.87 wiz 1642: with the OpenBSD userland tools. There are several steps:</p>
1.75 rillig 1643: <div class="orderedlist"><ol type="1">
1644: <li><p>OpenBSD stores its ports pkg database in
1.87 wiz 1645: <code class="filename">/var/db/pkg</code>. It is therefore
1646: recommended that you choose a different location (e.g.
1647: <code class="filename">/usr/pkgdb</code>) by
1648: using the --pkgdbdir option to the bootstrap script.</p></li>
1.75 rillig 1649: <li>
1650: <p>If you do not intend to use the OpenBSD ports tools, it's probably a
1.87 wiz 1651: good idea to move them out of the way to avoid confusion, e.g.</p>
1652: <pre class="screen">
1653: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sbin</code></strong>
1.75 rillig 1654: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_add pkg_add.orig</code></strong>
1655: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_create pkg_create.orig</code></strong>
1656: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_delete pkg_delete.orig</code></strong>
1.87 wiz 1657: <code class="prompt">#</code> <strong class="userinput"><code>mv pkg_info pkg_info.orig</code></strong>
1658: </pre>
1.75 rillig 1659: </li>
1660: <li>
1.76 rillig 1661: <p>An example <code class="filename">/etc/mk.conf</code> file will be placed in
1.87 wiz 1662: <code class="filename">/etc/mk.conf.example</code> file
1663: when you use the bootstrap script. OpenBSD's make program uses
1664: <code class="filename">/etc/mk.conf</code>
1665: as well. You can work around this by enclosing all the pkgsrc-specific parts
1666: of the file with:</p>
1667: <pre class="programlisting">
1668: .ifdef BSD_PKG_MK
1669: # pkgsrc stuff, e.g. insert defaults/mk.conf or similar here
1670: .else
1671: # OpenBSD stuff
1672: .endif
1673: </pre>
1.75 rillig 1674: </li>
1675: </ol></div>
1676: </div>
1677: <div class="sect2" lang="en">
1678: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1679: <a name="solaris"></a>3.3.7. Solaris</h3></div></div></div>
1.75 rillig 1680: <p>Solaris 2.6 through 9 are supported on both x86 and sparc.
1.87 wiz 1681: You will need a working C compiler. Both gcc 2.95.3 and
1682: Sun WorkShop 5 have been tested.</p>
1.75 rillig 1683: <p>The following packages are required on Solaris 8 for the bootstrap
1.87 wiz 1684: process and to build packages.</p>
1.75 rillig 1685: <div class="itemizedlist"><ul type="disc">
1686: <li><p>SUNWsprot</p></li>
1687: <li><p>SUNWarc</p></li>
1688: <li><p>SUNWbtool</p></li>
1689: <li><p>SUNWtoo</p></li>
1690: <li><p>SUNWlibm</p></li>
1691: </ul></div>
1.78 rillig 1692: <p>Please note that the use of GNU binutils on Solaris is
1.87 wiz 1693: <span class="emphasis"><em>not</em></span> supported, as of June 2006.</p>
1.75 rillig 1694: <p>Whichever compiler you use, please ensure the compiler tools and
1.87 wiz 1695: your $prefix are in your <code class="varname">PATH</code>. This includes
1696: <code class="filename">/usr/ccs/{bin,lib}</code>
1697: and e.g. <code class="filename">/usr/pkg/{bin,sbin}</code>.</p>
1.75 rillig 1698: <div class="sect3" lang="en">
1699: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1700: <a name="solaris-gcc-note"></a>3.3.7.1. If you are using gcc</h4></div></div></div>
1.75 rillig 1701: <p>It makes life much simpler if you only use the same gcc consistently
1.87 wiz 1702: for building all packages.</p>
1.75 rillig 1703: <p>It is recommended that an external gcc be used only for bootstrapping,
1.87 wiz 1704: then either build gcc from
1705: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/lang/gcc/README.html" target="_top"><code class="filename">lang/gcc</code></a> or install a binary gcc
1706: package, then remove gcc used during bootstrapping.</p>
1.75 rillig 1707: <p>Binary packages of gcc can be found through <a href="http://www.sun.com/bigadmin/common/freewareSearch.html" target="_top">http://www.sun.com/bigadmin/common/freewareSearch.html</a>.</p>
1708: </div>
1709: <div class="sect3" lang="en">
1710: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1711: <a name="solaris-sun-workshop-note"></a>3.3.7.2. If you are using Sun WorkShop</h4></div></div></div>
1.75 rillig 1712: <p>You will need at least the following packages installed (from WorkShop
1.87 wiz 1713: 5.0)</p>
1.75 rillig 1714: <div class="itemizedlist"><ul type="disc">
1715: <li><p>SPROcc
1.87 wiz 1716: - Sun WorkShop Compiler C 5.0</p></li>
1.75 rillig 1717: <li><p>SPROcpl
1.87 wiz 1718: - Sun WorkShop Compiler C++ 5.0</p></li>
1.75 rillig 1719: <li><p>SPROild
1.87 wiz 1720: - Sun WorkShop Incremental Linker</p></li>
1.75 rillig 1721: <li><p>SPROlang
1.87 wiz 1722: - Sun WorkShop Compilers common components</p></li>
1.75 rillig 1723: </ul></div>
1724: <p>You should set <code class="varname">CC</code>, <code class="varname">CXX</code> and
1.87 wiz 1725: optionally, <code class="varname">CPP</code> in <code class="filename">/etc/mk.conf</code>,
1726: e.g.:</p>
1.75 rillig 1727: <pre class="programlisting">
1.87 wiz 1728: CC= cc
1729: CXX= CC
1730: CPP= /usr/ccs/lib/cpp
1731: </pre>
1.75 rillig 1732: </div>
1733: <div class="sect3" lang="en">
1734: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1735: <a name="solaris-sunpro-64"></a>3.3.7.3. Buildling 64-bit binaries with SunPro</h4></div></div></div>
1.75 rillig 1736: <p>Building 64-bit binaries is a little trickier. First, you
1737: need to bootstrap pkgsrc in 64-bit mode. One problem here is
1738: that while building one of the programs in the bootstrap kit
1.76 rillig 1739: (<code class="filename">bmake</code>), the <code class="varname">CFLAGS</code>
1.75 rillig 1740: variable is not honored, even if it is set in the environment.
1741: To work around this bug, you can create a simple shell script
1.76 rillig 1742: called <code class="filename">cc64</code> and put it somewhere in the
1.75 rillig 1743: <code class="varname">PATH</code>:</p>
1744: <pre class="programlisting">
1.87 wiz 1745: #! /bin/sh
1746: exec /opt/SUNWspro/bin/cc -xtarget=ultra -xarch=v9 ${1+"$@"}
1747: </pre>
1.75 rillig 1748: <p>Then, pass the definition for <code class="varname">CC</code> in the
1749: environment of the <span><strong class="command">bootstrap</strong></span> command:</p>
1750: <pre class="programlisting">
1.87 wiz 1751: <code class="prompt">$</code> <strong class="userinput"><code>cd bootstrap</code></strong>
1752: <code class="prompt">$</code> <strong class="userinput"><code>CC=cc64 ./bootstrap</code></strong>
1753: </pre>
1.75 rillig 1754: <p>After bootstrapping, there are two alternative ways,
1755: depending on whether you want to find bugs in packages or get
1756: your system ready quickly. If you just want a running system,
1.76 rillig 1757: add the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1758: file:</p>
1759: <pre class="programlisting">
1.87 wiz 1760: CC= cc64
1761: CXX= CC64
1762: PKGSRC_COMPILER= sunpro
1763: </pre>
1.75 rillig 1764: <p>This way, all calls to the compiler will be intercepted by
1765: the above wrapper and therefore get the necessary ABI options
1766: automatically. (Don't forget to create the shell script
1.76 rillig 1767: <code class="filename">CC64</code>, too.)</p>
1.75 rillig 1768: <p>To find packages that ignore the user-specified
1769: <code class="varname">CFLAGS</code> and <code class="varname">CXXFLAGS</code>, add
1.76 rillig 1770: the following lines to your <code class="filename">mk.conf</code>
1.75 rillig 1771: file:</p>
1772: <pre class="programlisting">
1.87 wiz 1773: CC= cc
1774: CXX= CC
1775: PKGSRC_COMPILER= sunpro
1776: CFLAGS= -xtarget=ultra -xarch=v9
1777: CXXFLAGS= -xtarget=ultra -xarch=v9
1778: LDFLAGS= -xtarget=ultra -xarch=v9
1779: </pre>
1.75 rillig 1780: <p>Packages that don't use the flags provided in the
1781: configuration file will try to build 32-bit binaries and fail
1782: during linking. Detecting this is useful to prevent bugs on
1783: other platforms where the error would not show up but pass
1784: silently.</p>
1785: </div>
1786: <div class="sect3" lang="en">
1787: <div class="titlepage"><div><div><h4 class="title">
1.82 rillig 1788: <a name="plat.sunos.problems"></a>3.3.7.4. Common problems</h4></div></div></div>
1.75 rillig 1789: <p>Sometimes, when using <span><strong class="command">libtool</strong></span>,
1.87 wiz 1790: <code class="filename">/bin/ksh</code> crashes with a segmentation fault.
1791: The workaround is to use another shell for the configure
1792: scripts, for example by installing <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/shells/bash/README.html" target="_top"><code class="filename">shells/bash</code></a> and adding the following lines
1793: to your <code class="filename">mk.conf</code>:</p>
1794: <pre class="programlisting">
1795: CONFIG_SHELL= ${LOCALBASE}/bin/bash
1796: WRAPPER_SHELL= ${LOCALBASE}/bin/bash
1797: </pre>
1.76 rillig 1798: <p>Then, rebuild the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/libtool-base/README.html" target="_top"><code class="filename">devel/libtool-base</code></a> package.</p>
1.75 rillig 1799: </div>
1800: </div>
1801: </div>
1802: </div>
1803: <div class="chapter" lang="en">
1804: <div class="titlepage"><div><div><h2 class="title">
1805: <a name="using"></a>Chapter 4. Using pkgsrc</h2></div></div></div>
1806: <div class="toc">
1807: <p><b>Table of Contents</b></p>
1808: <dl>
1809: <dt><span class="sect1"><a href="#using-pkg">4.1. Using binary packages</a></span></dt>
1810: <dd><dl>
1811: <dt><span class="sect2"><a href="#finding-binary-packages">4.1.1. Finding binary packages</a></span></dt>
1812: <dt><span class="sect2"><a href="#installing-binary-packages">4.1.2. Installing binary packages</a></span></dt>
1.82 rillig 1813: <dt><span class="sect2"><a href="#using.pkg_delete">4.1.3. Deinstalling packages</a></span></dt>
1814: <dt><span class="sect2"><a href="#using.pkg_info">4.1.4. Getting information about installed packages</a></span></dt>
1815: <dt><span class="sect2"><a href="#vulnerabilities">4.1.5. Checking for security vulnerabilities in installed packages</a></span></dt>
1816: <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>
1817: <dt><span class="sect2"><a href="#using.pkg_admin">4.1.7. Other administrative functions</a></span></dt>
1818: <dt><span class="sect2"><a href="#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
1.75 rillig 1819: </dl></dd>
1820: <dt><span class="sect1"><a href="#building-packages-from-source">4.2. Building packages from source</a></span></dt>
1821: <dd><dl>
1822: <dt><span class="sect2"><a href="#requirements">4.2.1. Requirements</a></span></dt>
1823: <dt><span class="sect2"><a href="#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
1824: <dt><span class="sect2"><a href="#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
1825: </dl></dd>
1826: </dl>
1827: </div>
1828: <p>Basically, there are two ways of using pkgsrc. The first
1.88 wiz 1829: is to only install the package tools and to use binary packages
1830: that someone else has prepared. This is the “<span class="quote">pkg</span>”
1831: in pkgsrc. The second way is to install the “<span class="quote">src</span>”
1832: of pkgsrc, too. Then you are able to build your own packages,
1833: and you can still use binary packages from someone else.</p>
1.75 rillig 1834: <div class="sect1" lang="en">
1835: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1836: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
1837: <p>To use binary packages, you need some tools to manage
1.88 wiz 1838: them. On NetBSD, these tools are already installed. On all other
1839: operating systems, you need to install them first. For the
1840: following platforms, prebuilt versions of the package tools
1841: are available and can simply be downloaded and unpacked in the
1842: <code class="filename">/</code> directory:</p>
1.75 rillig 1843: <div class="informaltable">
1844: <a name="binary-bootstrap-kits"></a><table border="1">
1845: <colgroup>
1846: <col>
1847: <col>
1848: </colgroup>
1849: <thead><tr>
1850: <th>Platform</th>
1851: <th>URL</th>
1852: </tr></thead>
1853: <tbody>
1854: <tr>
1855: <td>Solaris 9</td>
1.76 rillig 1856: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1857: </tr>
1858: <tr>
1859: <td>Solaris 10</td>
1.76 rillig 1860: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/bootstrap-pkgsrc/</code></td>
1.75 rillig 1861: </tr>
1862: </tbody>
1863: </table>
1864: </div>
1.82 rillig 1865: <p>These pre-built package tools use
1.88 wiz 1866: <code class="filename">/usr/pkg</code> for the base directory, and
1867: <code class="filename">/var/db/pkg</code> for the database of installed
1868: packages. If you cannot use these directories for whatever
1869: reasons (maybe because you're not root), you have to build the
1870: package tools yourself, which is explained in <a href="#bootstrapping-pkgsrc" title="3.2. Bootstrapping pkgsrc">Section 3.2, “Bootstrapping pkgsrc”</a>.</p>
1.75 rillig 1871: <div class="sect2" lang="en">
1872: <div class="titlepage"><div><div><h3 class="title">
1873: <a name="finding-binary-packages"></a>4.1.1. Finding binary packages</h3></div></div></div>
1874: <p>To install binary packages, you first need to know from
1.88 wiz 1875: where to get them. You can get them on CD-ROMs, DVDs, or via FTP
1876: or HTTP.</p>
1.81 rillig 1877: <p>The binary packages can be found at the following
1.88 wiz 1878: locations.</p>
1.75 rillig 1879: <div class="informaltable">
1880: <a name="binary-packages"></a><table border="1">
1881: <colgroup>
1882: <col>
1883: <col>
1884: </colgroup>
1885: <thead><tr>
1886: <th>Platform</th>
1887: <th>URL</th>
1888: </tr></thead>
1889: <tbody>
1890: <tr>
1.81 rillig 1891: <td>NetBSD</td>
1892: <td><code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/</code></td>
1893: </tr>
1894: <tr>
1.75 rillig 1895: <td>Solaris 9</td>
1.76 rillig 1896: <td><code class="filename">ftp://ftp0.mh.bbc.co.uk/pub/pkgsrc/packages/</code></td>
1.75 rillig 1897: </tr>
1898: <tr>
1899: <td>Solaris 10</td>
1.76 rillig 1900: <td><code class="filename">http://public.enst.fr/pkgsrc/packages/</code></td>
1.75 rillig 1901: </tr>
1902: </tbody>
1903: </table>
1904: </div>
1.81 rillig 1905: <p>Most of these directories contain binary packages for
1.88 wiz 1906: multiple platforms. Select the appropriate subdirectories,
1907: according to your machine architecture and operating system,
1908: until you find a directory called <code class="filename">All</code>. This
1909: directory contains all the binary packages. Further, there are
1910: subdirectories for categories that contain symbolic links that
1911: point to the actual binary package in
1912: <code class="filename">../All</code>. This directory layout is used for
1913: all package repositories, no matter if they are accessed via
1914: HTTP, FTP, NFS, CD-ROM, or the local filesystem.</p>
1.75 rillig 1915: </div>
1916: <div class="sect2" lang="en">
1917: <div class="titlepage"><div><div><h3 class="title">
1918: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
1.87 wiz 1919: <p>If you have the files on a CD-ROM or downloaded them to
1.88 wiz 1920: your hard disk, you can install them with the following command
1921: (be sure to <span><strong class="command">su</strong></span> to root first):</p>
1.75 rillig 1922: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add /path/to/package.tgz</code></strong></pre>
1.87 wiz 1923: <p>If you have FTP access and you don't want to download the
1.88 wiz 1924: packages via FTP prior to installation, you can do this
1925: automatically by giving <span><strong class="command">pkg_add</strong></span> an FTP URL:</p>
1.82 rillig 1926: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add ftp://ftp.NetBSD.org/pub/NetBSD/packages/<OSVERSION>/<ARCH>/All/package</code></strong></pre>
1.75 rillig 1927: <p>Note that any prerequisite packages needed to run the
1.88 wiz 1928: package in question will be installed, too, assuming they are
1929: present where you install from.</p>
1.75 rillig 1930: <p>To save some typing, you can set the
1.88 wiz 1931: <code class="varname">PKG_PATH</code> environment variable to a semicolon-separated
1932: list of paths (including remote URLs); trailing slashes are not allowed.
1933: </p>
1.76 rillig 1934: <p>Additionally to the <code class="filename">All</code> directory
1.88 wiz 1935: there exists a <code class="filename">vulnerable</code> directory to
1936: which binary packages with known vulnerabilities are
1937: moved, since removing them could cause missing dependencies. To
1938: use these packages, add the <code class="filename">vulnerable</code>
1939: directory to your <code class="varname">PKG_PATH</code>. However, you should run
1940: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a> regularly,
1941: especially after installing new packages, and verify that the
1942: vulnerabilities are acceptable for your configuration. An example
1943: <code class="varname">PKG_PATH</code> would be:
1944: <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/<OSVERSION>/<ARCH>/All;ftp://ftp.NetBSD.org/pub/NetBSD/packages/<OSVERSION>/<ARCH>/vulnerable</code>
1945: Please note that semicolon (';') is a shell meta-character, so
1946: you'll probably have to quote it.</p>
1.75 rillig 1947: <p>After you've installed packages, be sure to have
1.88 wiz 1948: <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
1949: <code class="varname">PATH</code> so you can actually start the just
1950: installed program.</p>
1.75 rillig 1951: </div>
1952: <div class="sect2" lang="en">
1953: <div class="titlepage"><div><div><h3 class="title">
1.82 rillig 1954: <a name="using.pkg_delete"></a>4.1.3. Deinstalling packages</h3></div></div></div>
1955: <p>To deinstall a package, it does not matter whether it was
1.88 wiz 1956: installed from source code or from a binary package. The
1957: <span><strong class="command">pkg_delete</strong></span> command does not know it anyway.
1958: To delete a package, you can just run <span><strong class="command">pkg_delete
1959: <em class="replaceable"><code>package-name</code></em></strong></span>. The package
1960: name can be given with or without version number. Wildcards can
1961: also be used to deinstall a set of packages, for example
1962: <code class="literal">*emacs*</code>. Be sure to include them in quotes,
1963: so that the shell does not expand them before
1964: <code class="literal">pkg_delete</code> sees them.</p>
1.82 rillig 1965: <p>The <code class="option">-r</code> option is very powerful: it
1.88 wiz 1966: removes all the packages that require the package in question
1967: and then removes the package itself. For example:
1.82 rillig 1968:
1.88 wiz 1969: </p>
1.82 rillig 1970: <pre class="screen">
1.88 wiz 1971: <code class="prompt">#</code> <strong class="userinput"><code>pkg_delete -r jpeg</code></strong>
1972: </pre>
1.82 rillig 1973: <p>
1974:
1.88 wiz 1975: will remove jpeg and all the packages that used it; this allows
1976: upgrading the jpeg package.</p>
1.82 rillig 1977: </div>
1978: <div class="sect2" lang="en">
1979: <div class="titlepage"><div><div><h3 class="title">
1980: <a name="using.pkg_info"></a>4.1.4. Getting information about installed packages</h3></div></div></div>
1981: <p>The <span><strong class="command">pkg_info</strong></span> shows information about
1.88 wiz 1982: installed packages or binary package files.</p>
1.82 rillig 1983: </div>
1984: <div class="sect2" lang="en">
1985: <div class="titlepage"><div><div><h3 class="title">
1986: <a name="vulnerabilities"></a>4.1.5. Checking for security vulnerabilities in installed packages</h3></div></div></div>
1987: <p>
1.88 wiz 1988: The NetBSD Security-Officer and Packages Groups maintain a list of
1989: known security vulnerabilities to packages which are (or have been)
1990: included in pkgsrc. The list is available from the NetBSD
1991: FTP site at <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities</a>.
1992: </p>
1.82 rillig 1993: <p>
1.88 wiz 1994: Through <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>,
1995: this list can be downloaded
1996: automatically, and a security audit of all packages installed on a system
1997: can take place.
1998: </p>
1.82 rillig 1999: <p>
1.88 wiz 2000: There are two components to
2001: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>. The first
2002: component, “<span class="quote">download-vulnerability-list</span>”, is for downloading
2003: the list of vulnerabilities from the NetBSD FTP site. The second
2004: component, “<span class="quote">audit-packages</span>”, checks to see if any of your
2005: installed packages are vulnerable. If a package is vulnerable, you
2006: will see output similar to the following:
2007: </p>
1.82 rillig 2008: <pre class="screen">Package samba-2.0.9 has a local-root-shell vulnerability, see
1.88 wiz 2009: http://www.samba.org/samba/whatsnew/macroexploit.html</pre>
1.82 rillig 2010: <p>
1.88 wiz 2011: One can set up <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a> to download the
2012: <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">vulnerabilities</a>
2013: file daily, and include a package audit in the daily security script.
2014: Details on this are located in the <a href="http://cvsweb.NetBSD.org/bsdweb.cgi/pkgsrc/security/audit-packages/MESSAGE?rev=HEAD&content-type=text/x-cvsweb-markup" target="_top">MESSAGE</a>
2015: file for <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>.
2016: </p>
1.82 rillig 2017: </div>
2018: <div class="sect2" lang="en">
2019: <div class="titlepage"><div><div><h3 class="title">
2020: <a name="pkg_versions"></a>4.1.6. Finding if newer versions of your installed packages are in pkgsrc</h3></div></div></div>
2021: <p>
1.88 wiz 2022: Install <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a> and run
2023: <span><strong class="command">lintpkgsrc</strong></span> with the “<span class="quote">-i</span>”
2024: argument to check if your packages are up-to-date, e.g.
2025: </p>
2026: <pre class="screen">
2027: <code class="prompt">%</code> <strong class="userinput"><code>lintpkgsrc -i</code></strong>
1.82 rillig 2028: ...
1.88 wiz 2029: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
2030: </pre>
1.82 rillig 2031: <p>You can then use <span><strong class="command">make update</strong></span> to update the
1.88 wiz 2032: package on your system and rebuild any dependencies.
2033: </p>
1.82 rillig 2034: </div>
2035: <div class="sect2" lang="en">
2036: <div class="titlepage"><div><div><h3 class="title">
2037: <a name="using.pkg_admin"></a>4.1.7. Other administrative functions</h3></div></div></div>
2038: <p>The <span><strong class="command">pkg_admin</strong></span> executes various
1.88 wiz 2039: administrative functions on the package system.</p>
1.82 rillig 2040: </div>
2041: <div class="sect2" lang="en">
2042: <div class="titlepage"><div><div><h3 class="title">
2043: <a name="a-word-of-warning"></a>4.1.8. A word of warning</h3></div></div></div>
1.75 rillig 2044: <p>Please pay very careful attention to the warnings
1.88 wiz 2045: expressed in the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> manual page about the
2046: inherent dangers of installing binary packages which you did
2047: not create yourself, and the security holes that can be
2048: introduced onto your system by indiscriminate adding of such
2049: files.</p>
1.75 rillig 2050: <p>The same warning of course applies to every package you
1.88 wiz 2051: install from source when you haven't completely read and
2052: understood the source code of the package, the compiler that
2053: is used to build the package and all the other tools that are
2054: involved.</p>
1.75 rillig 2055: </div>
2056: </div>
2057: <div class="sect1" lang="en">
2058: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2059: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
1.88 wiz 2060: <p>After obtaining pkgsrc, the <code class="filename">pkgsrc</code>
2061: directory now contains a set of packages, organized into
2062: categories. You can browse the online index of packages, or run
2063: <span><strong class="command">make readme</strong></span> from the <code class="filename">pkgsrc</code>
2064: directory to build local <code class="filename">README.html</code> files for
2065: all packages, viewable with any web browser such as <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/lynx/README.html" target="_top"><code class="filename">www/lynx</code></a> or <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a>.</p>
2066: <p>The default <span class="emphasis"><em>prefix</em></span> for installed packages
2067: is <code class="filename">/usr/pkg</code>. If you wish to change this, you
2068: should do so by setting <code class="varname">LOCALBASE</code> in
2069: <code class="filename">mk.conf</code>. You should not try to use multiple
2070: different <code class="varname">LOCALBASE</code> definitions on the same
2071: system (inside a chroot is an exception). </p>
2072: <p>The rest of this chapter assumes that the package is already
2073: in pkgsrc. If it is not, see <a href="#developers-guide" title="Part II. The pkgsrc developer's guide">Part II, “The pkgsrc developer's guide”</a> for
2074: instructions how to create your own packages.</p>
1.75 rillig 2075: <div class="sect2" lang="en">
2076: <div class="titlepage"><div><div><h3 class="title">
2077: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
1.82 rillig 2078: <p>To build packages from source, you need a working C
1.88 wiz 2079: compiler. On NetBSD, you need to install the
2080: “<span class="quote">comp</span>” and the “<span class="quote">text</span>” distribution
2081: sets. If you want to build X11-related packages, the
2082: “<span class="quote">xbase</span>” and “<span class="quote">xcomp</span>” distribution
2083: sets are required, too.</p>
1.75 rillig 2084: </div>
2085: <div class="sect2" lang="en">
2086: <div class="titlepage"><div><div><h3 class="title">
2087: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
2088: <p>The first step for building a package is downloading the
1.88 wiz 2089: distfiles (i.e. the unmodified source). If they have not yet been
2090: downloaded, pkgsrc will fetch them automatically.</p>
2091: <p>If you have all files that you need in the
2092: <code class="filename">distfiles</code> directory,
2093: you don't need to connect. If the distfiles are on CD-ROM, you can
2094: mount the CD-ROM on <code class="filename">/cdrom</code> and add:
2095: </p>
1.82 rillig 2096: <pre class="screen">DISTDIR=/cdrom/pkgsrc/distfiles</pre>
2097: <p>
1.88 wiz 2098: to your <code class="filename">mk.conf</code>.</p>
2099: <p>You can overwrite some of the major distribution sites to
2100: fit to sites that are close to your own. By setting one or two
2101: variables you can modify the order in which the master sites are
2102: accessed. <code class="varname">MASTER_SORT</code> contains a whitespace
2103: delimited list of domain suffixes.
2104: <code class="varname">MASTER_SORT_REGEX</code> is even more flexible, it
2105: contains a whitespace delimited list of regular expressions. It
2106: has higher priority than <code class="varname">MASTER_SORT</code>. Have a
2107: look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find
2108: some examples. This may save some of your bandwidth and
2109: time.</p>
1.75 rillig 2110: <p>You can change these settings either in your shell's environment, or,
1.88 wiz 2111: if you want to keep the settings, by editing the
2112: <code class="filename">/etc/mk.conf</code> file,
2113: and adding the definitions there.</p>
1.82 rillig 2114: <p>
1.88 wiz 2115: If a package depends on many other packages (such as
2116: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/kde3/README.html" target="_top"><code class="filename">meta-pkgs/kde3</code></a>), the build process may
2117: alternate between periods of
2118: downloading source, and compiling. To ensure you have all the source
2119: downloaded initially you can run the command:
2120: </p>
1.82 rillig 2121: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch-list | sh</code></strong></pre>
2122: <p>
1.88 wiz 2123: which will output and run a set of shell commands to fetch the
2124: necessary files into the <code class="filename">distfiles</code> directory. You can
2125: also choose to download the files manually.
2126: </p>
1.75 rillig 2127: </div>
2128: <div class="sect2" lang="en">
2129: <div class="titlepage"><div><div><h3 class="title">
2130: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
1.82 rillig 2131: <p>
1.88 wiz 2132: Once the software has downloaded, any patches will be applied, then it
2133: will be compiled for you. This may take some time depending on your
2134: computer, and how many other packages the software depends on and their
2135: compile time.
2136: </p>
1.75 rillig 2137: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
2138: <h3 class="title">Note</h3>
2139: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
1.88 wiz 2140: use the pkgsrc <span><strong class="command">bmake</strong></span> command instead of
2141: “<span class="quote">make</span>” in the examples in this guide.</p>
1.75 rillig 2142: </div>
1.87 wiz 2143: <p>For example, type</p>
1.88 wiz 2144: <pre class="screen">
2145: <code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
2146: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
2147: </pre>
1.75 rillig 2148: <p>at the shell prompt to build the various components of the
1.88 wiz 2149: package.</p>
1.82 rillig 2150: <p>The next stage is to actually install the newly compiled
1.88 wiz 2151: program onto your system. Do this by entering:
1.82 rillig 2152:
1.88 wiz 2153: </p>
1.82 rillig 2154: <pre class="screen">
1.88 wiz 2155: <code class="prompt">%</code> <strong class="userinput"><code>make install</code></strong>
2156: </pre>
1.82 rillig 2157: <p>
2158:
1.88 wiz 2159: while you are still in the directory for whatever package you
2160: are installing.</p>
1.82 rillig 2161: <p>Installing the package on your system may require you to
1.88 wiz 2162: be root. However, pkgsrc has a
2163: <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
2164: to only become root for the actual installation step.</p>
1.82 rillig 2165: <p>That's it, the software should now be installed and setup for use.
1.88 wiz 2166: You can now enter:
1.82 rillig 2167:
1.88 wiz 2168: </p>
1.82 rillig 2169: <pre class="screen">
1.88 wiz 2170: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong>
2171: </pre>
1.82 rillig 2172: <p>
2173:
1.88 wiz 2174: to remove the compiled files in the work directory, as you shouldn't need
2175: them any more. If other packages were also added to your system
2176: (dependencies) to allow your program to compile, you can tidy these up
2177: also with the command:</p>
1.82 rillig 2178: <pre class="screen">
1.88 wiz 2179: <code class="prompt">%</code> <strong class="userinput"><code>make clean-depends</code></strong>
2180: </pre>
1.75 rillig 2181: <p>Taking the figlet utility as an example, we can install it on our
1.88 wiz 2182: system by building as shown in <a href="#logs" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
2183: <p>The program is installed under the default root of the
2184: packages tree - <code class="filename">/usr/pkg</code>. Should this not
2185: conform to your tastes, set the <code class="varname">LOCALBASE</code>
2186: variable in your environment, and it will use that value as the
2187: root of your packages tree. So, to use
2188: <code class="filename">/usr/local</code>, set
2189: <code class="varname">LOCALBASE=/usr/local</code> in your environment.
2190: Please note that you should use a directory which is dedicated to
2191: packages and not shared with other programs (i.e., do not try and
2192: use <code class="varname">LOCALBASE=/usr</code>). Also, you should not try
2193: to add any of your own files or directories (such as
2194: <code class="filename">src/</code>, <code class="filename">obj/</code>, or
2195: <code class="filename">pkgsrc/</code>) below the
2196: <code class="varname">LOCALBASE</code> tree. This is to prevent possible
2197: conflicts between programs and other files installed by the
2198: package system and whatever else may have been installed
2199: there.</p>
2200: <p>Some packages look in <code class="filename">/etc/mk.conf</code> to
2201: alter some configuration options at build time. Have a look at
2202: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to get an overview
2203: of what will be set there by default. Environment variables such
2204: as <code class="varname">LOCALBASE</code> can be set in
2205: <code class="filename">/etc/mk.conf</code> to save having to remember to
2206: set them each time you want to use pkgsrc.</p>
2207: <p>Occasionally, people want to “<span class="quote">look under the
2208: covers</span>” to see what is going on when a package is building
2209: or being installed. This may be for debugging purposes, or out of
2210: simple curiosity. A number of utility values have been added to
2211: help with this.</p>
1.75 rillig 2212: <div class="orderedlist"><ol type="1">
2213: <li>
1.88 wiz 2214: <p>If you invoke the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> command with
2215: <code class="varname">PKG_DEBUG_LEVEL=2</code>, then a huge amount of
2216: information will be displayed. For example,</p>
1.75 rillig 2217: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
1.88 wiz 2218: <p>will show all the commands that are invoked, up to and
2219: including the “<span class="quote">patch</span>” stage.</p>
1.75 rillig 2220: </li>
2221: <li>
1.88 wiz 2222: <p>If you want to know the value of a certain <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>
2223: definition, then the <code class="varname">VARNAME</code> definition
2224: should be used, in conjunction with the show-var
2225: target. e.g. to show the expansion of the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>
2226: variable <code class="varname">LOCALBASE</code>:</p>
2227: <pre class="screen">
2228: <code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
1.75 rillig 2229: /usr/pkg
2230: <code class="prompt">%</code>
1.88 wiz 2231: </pre>
1.75 rillig 2232: </li>
2233: </ol></div>
2234: <p>If you want to install a binary package that you've either
1.88 wiz 2235: created yourself (see next section), that you put into
2236: pkgsrc/packages manually or that is located on a remote FTP
2237: server, you can use the "bin-install" target. This target will
2238: install a binary package - if available - via <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>,
2239: else do a <span><strong class="command">make package</strong></span>. The list of remote FTP
2240: sites searched is kept in the variable
2241: <code class="varname">BINPKG_SITES</code>, which defaults to
2242: ftp.NetBSD.org. Any flags that should be added to <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>
2243: can be put into <code class="varname">BIN_INSTALL_FLAGS</code>. See
2244: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more
2245: details.</p>
2246: <p>A final word of warning: If you set up a system that has a
2247: non-standard setting for <code class="varname">LOCALBASE</code>, be sure to
2248: set that before any packages are installed, as you cannot use
2249: several directories for the same purpose. Doing so will result in
2250: pkgsrc not being able to properly detect your installed packages,
2251: and fail miserably. Note also that precompiled binary packages are
2252: usually built with the default <code class="varname">LOCALBASE</code> of
2253: <code class="filename">/usr/pkg</code>, and that you should
2254: <span class="emphasis"><em>not</em></span> install any if you use a non-standard
2255: <code class="varname">LOCALBASE</code>.</p>
1.75 rillig 2256: </div>
2257: </div>
2258: </div>
2259: <div class="chapter" lang="en">
2260: <div class="titlepage"><div><div><h2 class="title">
2261: <a name="configuring"></a>Chapter 5. Configuring pkgsrc</h2></div></div></div>
2262: <div class="toc">
2263: <p><b>Table of Contents</b></p>
2264: <dl>
2265: <dt><span class="sect1"><a href="#general-configuration">5.1. General configuration</a></span></dt>
2266: <dt><span class="sect1"><a href="#variables-affecting-build">5.2. Variables affecting the build process</a></span></dt>
1.78 rillig 2267: <dt><span class="sect1"><a href="#conf.compiler">5.3. Selecting and configuring the compiler</a></span></dt>
1.88 wiz 2268: <dd><dl>
1.89 rillig 2269: <dt><span class="sect2"><a href="#selecting-the-compiler">5.3.1. Selecting the compiler</a></span></dt>
2270: <dt><span class="sect2"><a href="#conf.cflags">5.3.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</a></span></dt>
2271: <dt><span class="sect2"><a href="#conf.ldflags">5.3.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</a></span></dt>
1.88 wiz 2272: </dl></dd>
1.78 rillig 2273: <dt><span class="sect1"><a href="#developer-advanced-settings">5.4. Developer/advanced settings</a></span></dt>
2274: <dt><span class="sect1"><a href="#selecting-build-options">5.5. Selecting Build Options</a></span></dt>
1.75 rillig 2275: </dl>
2276: </div>
1.89 rillig 2277: <p>The whole pkgsrc system is configured in a single file, usually
2278: called <code class="filename">mk.conf</code>. In which directory pkgsrc looks for
2279: that file depends on the installation. On NetBSD, when you use
2280: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> from the base system, it is in the directory
2281: <code class="filename">/etc/</code>. In all other cases the default location is
2282: <code class="literal">${PREFIX}/etc/</code>, depending on where you told the
2283: bootstrap program to install the binary packages.</p>
2284: <p>During the bootstrap, an example configuration file is created. To
2285: use that, you have to create the directory
2286: <code class="filename">${PREFIX}/etc</code> and copy the example file
2287: there.</p>
2288: <p>The format of the configuration file is that of the usual
2289: BSD-style <code class="filename">Makefile</code>s. The whole pkgsrc configuration
2290: is done by setting variables in this file. Note that you can define all
2291: kinds of variables, and no special error checking (for example for
2292: spelling mistakes) takes place, so you have to try it out to see if it
2293: works.</p>
1.75 rillig 2294: <div class="sect1" lang="en">
2295: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2296: <a name="general-configuration"></a>5.1. General configuration</h2></div></div></div>
2297: <p>In this section, you can find some variables that apply to all
1.89 rillig 2298: pkgsrc packages. A complete list of the variables that can be
2299: configured by the user is available in
2300: <code class="filename">mk/defaults/mk.conf</code>, together with some
2301: comments that describe each variable's intent.</p>
1.75 rillig 2302: <div class="itemizedlist"><ul type="disc">
2303: <li><p><code class="varname">LOCALBASE</code>: Where
2304: packages will be installed. The default is
1.76 rillig 2305: <code class="filename">/usr/pkg</code>. Do not mix binary packages
1.75 rillig 2306: with different <code class="varname">LOCALBASE</code>s!</p></li>
2307: <li><p><code class="varname">CROSSBASE</code>: Where
2308: “<span class="quote">cross</span>” category packages will be
2309: installed. The default is
1.76 rillig 2310: <code class="filename">${LOCALBASE}/cross</code>.</p></li>
1.75 rillig 2311: <li><p><code class="varname">X11BASE</code>: Where
2312: X11 is installed on the system. The default is
1.76 rillig 2313: <code class="filename">/usr/X11R6</code>.</p></li>
1.75 rillig 2314: <li><p><code class="varname">DISTDIR</code>: Where to store the
2315: downloaded copies of the original source distributions used
2316: for building pkgsrc packages. The default is
1.76 rillig 2317: <code class="filename">${PKGSRCDIR}/distfiles</code>.</p></li>
1.75 rillig 2318: <li><p><code class="varname">MASTER_SITE_OVERRIDE</code>:
2319: If set, override the packages'
2320: <code class="varname">MASTER_SITES</code> with this value.</p></li>
2321: <li><p><code class="varname">MASTER_SITE_BACKUP</code>:
2322: Backup location(s) for distribution files and patch files
2323: if not found locally or in
1.76 rillig 2324: <code class="filename">${MASTER_SITES}</code> or
2325: <code class="filename">${PATCH_SITES}</code> respectively.
1.75 rillig 2326: The defaults are
1.76 rillig 2327: <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}/</code>
1.75 rillig 2328: and
1.76 rillig 2329: <code class="filename">ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/</code>.</p></li>
1.75 rillig 2330: <li><p><code class="varname">BINPKG_SITES</code>:
2331: List of sites carrying binary pkgs.</p></li>
1.82 rillig 2332: <li><p><code class="varname">ACCEPTABLE_LICENSES</code>:
2333: List of acceptable licenses. Whenever you try to build a package
2334: whose license is not in this list, you will get an error message
2335: that includes instructions on how to change this variable.</p></li>
1.75 rillig 2336: </ul></div>
2337: </div>
2338: <div class="sect1" lang="en">
2339: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2340: <a name="variables-affecting-build"></a>5.2. Variables affecting the build process</h2></div></div></div>
2341: <p>XXX
2342: </p>
2343: <div class="itemizedlist"><ul type="disc">
2344: <li><p><code class="varname">PACKAGES</code>: The top level
2345: directory for the binary packages. The default is
1.76 rillig 2346: <code class="filename">${PKGSRCDIR}/packages</code>.</p></li>
1.75 rillig 2347: <li><p><code class="varname">WRKOBJDIR</code>:
2348: The top level directory where, if defined, the separate
2349: working directories will get created, and symbolically
1.76 rillig 2350: linked to from <code class="filename">${WRKDIR}</code> (see below).
1.75 rillig 2351: This is useful for building packages on several
1.76 rillig 2352: architectures, then <code class="filename">${PKGSRCDIR}</code>
2353: can be NFS-mounted while <code class="filename">${WRKOBJDIR}</code>
1.75 rillig 2354: is local to every architecture. (It should be noted that
2355: <code class="varname">PKGSRCDIR</code> should not be set by the user
1.89 rillig 2356: — it is an internal definition which refers to the
1.75 rillig 2357: root of the pkgsrc tree. It is possible to have many
2358: pkgsrc tree instances.)</p></li>
2359: <li><p><code class="varname">LOCALPATCHES</code>:
2360: Directory for local patches that aren't part of pkgsrc.
1.90 ! rillig 2361: See <a href="#components.patches" title="10.3. patches/*">Section 10.3, “patches/*”</a> for more
1.75 rillig 2362: information. <em class="replaceable"><code>rel</code></em> and
2363: <em class="replaceable"><code>arch</code></em> are replaced with OS
2364: release (“<span class="quote">2.0</span>”, etc.) and architecture
2365: (“<span class="quote">mipsel</span>”, etc.).</p></li>
2366: <li><p><code class="varname">PKGMAKECONF</code>: Location of
1.76 rillig 2367: the <code class="filename">mk.conf</code> file used by a package's
1.75 rillig 2368: BSD-style Makefile. If this is not set,
2369: <code class="varname">MAKECONF</code> is set to
1.76 rillig 2370: <code class="filename">/dev/null</code> to avoid picking up
2371: settings used by builds in <code class="filename">/usr/src</code>.</p></li>
1.82 rillig 2372: <li><p><code class="varname">DEPENDS_TARGET</code>:
2373: By default, dependencies are only installed, and no binary
2374: package is created for them. You can set this variable to
2375: <code class="literal">package</code> to automatically create binary
2376: packages after installing dependencies.</p></li>
1.75 rillig 2377: </ul></div>
2378: </div>
2379: <div class="sect1" lang="en">
2380: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 2381: <a name="conf.compiler"></a>5.3. Selecting and configuring the compiler</h2></div></div></div>
2382: <div class="sect2" lang="en">
2383: <div class="titlepage"><div><div><h3 class="title">
1.89 rillig 2384: <a name="selecting-the-compiler"></a>5.3.1. Selecting the compiler</h3></div></div></div>
2385: <p>By default, pkgsrc will use GCC to build packages. This may be
2386: overridden by setting the following variables in /etc/mk.conf:</p>
2387: <div class="variablelist"><dl>
2388: <dt><span class="term"><code class="varname">PKGSRC_COMPILER</code>:</span></dt>
2389: <dd>
2390: <p>This is a list of values specifying the chain of
2391: compilers to invoke when building packages. Valid values
2392: are:</p>
2393: <div class="itemizedlist"><ul type="disc">
2394: <li><p><code class="varname">distcc</code>:
2395: distributed C/C++ (chainable)</p></li>
2396: <li><p><code class="varname">ccache</code>:
2397: compiler cache (chainable)</p></li>
2398: <li><p><code class="varname">gcc</code>:
2399: GNU C/C++ Compiler</p></li>
2400: <li><p><code class="varname">mipspro</code>:
2401: Silicon Graphics, Inc. MIPSpro (n32/n64)</p></li>
2402: <li><p><code class="varname">mipspro</code>:
2403: Silicon Graphics, Inc. MIPSpro (o32)</p></li>
2404: <li><p><code class="varname">sunpro</code>:
2405: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio</p></li>
2406: </ul></div>
2407: <p>The default is
2408: “<span class="quote"><code class="varname">gcc</code></span>”. You can use
2409: <code class="varname">ccache</code> and/or
2410: <code class="varname">distcc</code> with an appropriate
2411: <code class="varname">PKGSRC_COMPILER</code> setting,
2412: e.g. “<span class="quote"><code class="varname">ccache gcc</code></span>”. This
2413: variable should always be
2414: terminated with a value for a real compiler.</p>
2415: </dd>
2416: <dt><span class="term"><code class="varname">GCC_REQD</code>:</span></dt>
2417: <dd><p>This specifies the minimum version of GCC to use
2418: when building packages. If the system GCC doesn't
2419: satisfy this requirement, then pkgsrc will build and
2420: install one of the GCC packages to use instead.</p></dd>
2421: </dl></div>
2422: </div>
2423: <div class="sect2" lang="en">
2424: <div class="titlepage"><div><div><h3 class="title">
2425: <a name="conf.cflags"></a>5.3.2. Additional flags to the compiler (<code class="varname">CFLAGS</code>)</h3></div></div></div>
1.78 rillig 2426: <p>If you wish to set the <code class="varname">CFLAGS</code> variable,
2427: please make sure to use the <code class="literal">+=</code> operator
2428: instead of the <code class="literal">=</code> operator:</p>
2429: <pre class="programlisting">
2430: CFLAGS+= -your -flags
2431: </pre>
2432: <p>Using <code class="varname">CFLAGS=</code> (i.e. without the
2433: “<span class="quote">+</span>”) may lead to problems with packages that need
2434: to add their own flags. Also, you may want to take a look at
2435: the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/cpuflags/README.html" target="_top"><code class="filename">devel/cpuflags</code></a> package if
2436: you're interested in optimization for the current CPU.</p>
2437: </div>
1.88 wiz 2438: <div class="sect2" lang="en">
2439: <div class="titlepage"><div><div><h3 class="title">
1.89 rillig 2440: <a name="conf.ldflags"></a>5.3.3. Additional flags to the linker (<code class="varname">LDFLAGS</code>)</h3></div></div></div>
1.88 wiz 2441: <p>If you want to pass flags to the linker, both in the configure
2442: step and the build step, you can do this in two ways. Either set
2443: <code class="varname">LDFLAGS</code> or <code class="varname">LIBS</code>. The difference
2444: between the two is that <code class="varname">LIBS</code> will be appended to
2445: the command line, while <code class="varname">LDFLAGS</code> come earlier.
2446: <code class="varname">LDFLAGS</code> is pre-loaded with rpath settings for ELF
2447: machines depending on the setting of <code class="varname">USE_IMAKE</code> or
2448: the inclusion of <code class="filename">mk/x11.buildlink3.mk</code>. As with
2449: <code class="varname">CFLAGS</code>, if you do not wish to override these
2450: settings, use the <code class="literal">+=</code> operator:</p>
2451: <pre class="programlisting">
2452: LDFLAGS+= -your -linkerflags
2453: </pre>
2454: </div>
1.78 rillig 2455: </div>
2456: <div class="sect1" lang="en">
2457: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2458: <a name="developer-advanced-settings"></a>5.4. Developer/advanced settings</h2></div></div></div>
1.75 rillig 2459: <p>XXX
2460: </p>
2461: <div class="itemizedlist"><ul type="disc">
2462: <li>
2463: <p><code class="varname">PKG_DEVELOPER</code>:
2464: Run some sanity checks that package developers want:
2465: </p>
2466: <div class="itemizedlist"><ul type="circle">
1.88 wiz 2467: <li><p>make sure patches apply with zero
2468: fuzz</p></li>
2469: <li><p>run check-shlibs to see that all
2470: binaries will find their shared libs.</p></li>
1.75 rillig 2471: </ul></div>
2472: <p>
1.87 wiz 2473: </p>
1.75 rillig 2474: </li>
1.88 wiz 2475: <li><p><code class="varname">PKG_DEBUG_LEVEL</code>: The level
2476: of debugging output which is displayed whilst making and
2477: installing the package. The default value for this is 0,
2478: which will not display the commands as they are executed
2479: (normal, default, quiet operation); the value 1 will display
2480: all shell commands before their invocation, and the value 2
2481: will display both the shell commands before their invocation,
2482: and their actual execution progress with <span><strong class="command">set
2483: -x</strong></span> will be displayed.</p></li>
1.75 rillig 2484: </ul></div>
2485: <p>
2486: </p>
2487: </div>
2488: <div class="sect1" lang="en">
2489: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.78 rillig 2490: <a name="selecting-build-options"></a>5.5. Selecting Build Options</h2></div></div></div>
1.88 wiz 2491: <p>Some packages have build time options, usually to select
2492: between different dependencies, enable optional support for big
2493: dependencies or enable experimental features.</p>
1.75 rillig 2494: <p>To see which options, if any, a package supports, and which
1.88 wiz 2495: options are mutually exclusive, run <span><strong class="command">make
2496: show-options</strong></span>, for example:</p>
1.75 rillig 2497: <pre class="programlisting">
2498: The following options are supported by this package:
2499: ssl Enable SSL support.
2500: Exactly one of the following gecko options is required:
2501: firefox Use firefox as gecko rendering engine.
2502: mozilla Use mozilla as gecko rendering engine.
2503: At most one of the following database options may be selected:
2504: mysql Enable support for MySQL database.
2505: pgsql Enable support for PostgreSQL database.
1.1 grant 2506:
1.75 rillig 2507: These options are enabled by default: firefox
2508: These options are currently enabled: mozilla ssl
1.1 grant 2509: </pre>
1.75 rillig 2510: <p>The following variables can be defined in
1.88 wiz 2511: <code class="filename">/etc/mk.conf</code> to select which options to
2512: enable for a package: <code class="varname">PKG_DEFAULT_OPTIONS</code>,
2513: which can be used to select or disable options for all packages
2514: that support them, and
2515: <code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>,
2516: which can be used to select or disable options specifically for
2517: package <em class="replaceable"><code>pkgbase</code></em>. Options listed in
2518: these variables are selected, options preceded by “<span class="quote">-</span>”
2519: are disabled. A few examples:</p>
1.75 rillig 2520: <pre class="screen">
2521: <code class="prompt">$</code> <span><strong class="command">grep "PKG.*OPTION" /etc/mk.conf</strong></span>
2522: PKG_DEFAULT_OPTIONS= -arts -dvdread -esound
2523: PKG_OPTIONS.kdebase= debug -sasl
2524: PKG_OPTIONS.apache= suexec </pre>
1.88 wiz 2525: <p>The following settings are consulted in the order given, and
2526: the last setting that selects or disables an option is
2527: used:</p>
1.75 rillig 2528: <div class="orderedlist"><ol type="1">
2529: <li><p>the default options as suggested by the package
1.88 wiz 2530: maintainer</p></li>
1.75 rillig 2531: <li><p>the options implied by the settings of legacy
1.88 wiz 2532: variables (see below)</p></li>
1.75 rillig 2533: <li><p><code class="varname">PKG_DEFAULT_OPTIONS</code></p></li>
2534: <li><p><code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code></p></li>
2535: </ol></div>
2536: <p>For groups of mutually exclusive options, the last option
1.88 wiz 2537: selected is used, all others are automatically disabled. If an
2538: option of the group is explicitly disabled, the previously
2539: selected option, if any, is used. It is an error if no option
2540: from a required group of options is selected, and building the
2541: package will fail.</p>
2542: <p>Before the options framework was introduced, build options
2543: were selected by setting a variable (often named
2544: <code class="varname">USE_<em class="replaceable"><code>FOO</code></em></code>) in
2545: <code class="filename">/etc/mk.conf</code> for each option. To ease
2546: transition to the options framework for the user, these legacy
2547: variables are converted to the appropriate options setting
2548: (<code class="varname">PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em></code>)
2549: automatically. A warning is issued to prompt the user to update
2550: <code class="filename">/etc/mk.conf</code> to use the options framework
2551: directly. Support for the legacy variables will be removed
2552: eventually.</p>
1.75 rillig 2553: </div>
2554: </div>
2555: <div class="chapter" lang="en">
2556: <div class="titlepage"><div><div><h2 class="title">
2557: <a name="binary"></a>Chapter 6. Creating binary packages</h2></div></div></div>
2558: <div class="toc">
2559: <p><b>Table of Contents</b></p>
2560: <dl>
2561: <dt><span class="sect1"><a href="#building-a-single-binary-package">6.1. Building a single binary package</a></span></dt>
2562: <dt><span class="sect1"><a href="#settings-for-creationg-of-binary-packages">6.2. Settings for creation of binary packages</a></span></dt>
2563: <dt><span class="sect1"><a href="#bulkbuild">6.3. Doing a bulk build of all packages</a></span></dt>
2564: <dd><dl>
2565: <dt><span class="sect2"><a href="#binary.configuration">6.3.1. Configuration</a></span></dt>
2566: <dt><span class="sect2"><a href="#other-environmental-considerations">6.3.2. Other environmental considerations</a></span></dt>
2567: <dt><span class="sect2"><a href="#operation">6.3.3. Operation</a></span></dt>
2568: <dt><span class="sect2"><a href="#what-it-does">6.3.4. What it does</a></span></dt>
2569: <dt><span class="sect2"><a href="#disk-space-requirements">6.3.5. Disk space requirements</a></span></dt>
2570: <dt><span class="sect2"><a href="#setting-up-a-sandbox">6.3.6. Setting up a sandbox for chrooted builds</a></span></dt>
2571: <dt><span class="sect2"><a href="#building-a-partial-set">6.3.7. Building a partial set of packages</a></span></dt>
2572: <dt><span class="sect2"><a href="#bulk-upload">6.3.8. Uploading results of a bulk build</a></span></dt>
2573: </dl></dd>
2574: <dt><span class="sect1"><a href="#creating-cdroms">6.4. Creating a multiple CD-ROM packages collection</a></span></dt>
2575: <dd><dl><dt><span class="sect2"><a href="#cdpack-example">6.4.1. Example of cdpack</a></span></dt></dl></dd>
2576: </dl>
2577: </div>
2578: <div class="sect1" lang="en">
2579: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2580: <a name="building-a-single-binary-package"></a>6.1. Building a single binary package</h2></div></div></div>
1.87 wiz 2581: <p>Once you have built and installed a package, you can create
2582: a <span class="emphasis"><em>binary package</em></span> which can be installed on
2583: another system with <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>. This saves having to build
2584: the same package on a group of hosts and wasting CPU time. It also
2585: provides a simple means for others to install your package, should
2586: you distribute it.</p>
2587: <p>To create a binary package, change into the appropriate
2588: directory in pkgsrc, and run <span><strong class="command">make
2589: package</strong></span>:</p>
2590: <pre class="screen">
2591: <code class="prompt">#</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
2592: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
2593: </pre>
2594: <p>This will build and install your package (if not already done),
2595: and then build a binary package from what was installed. You can
2596: then use the <span><strong class="command">pkg_*</strong></span> tools to manipulate
2597: it. Binary packages are created by default in
2598: <code class="filename">/usr/pkgsrc/packages</code>, in the form of a
2599: gzipped tar file. See <a href="#logs.package" title="B.2. Packaging figlet">Section B.2, “Packaging figlet”</a> for a
2600: continuation of the above <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/misc/figlet/README.html" target="_top"><code class="filename">misc/figlet</code></a> example.</p>
1.90 ! rillig 2601: <p>See <a href="#submit" title="Chapter 20. Submitting and Committing">Chapter 20, <i>Submitting and Committing</i></a> for information on how to submit
1.87 wiz 2602: such a binary package.</p>
1.75 rillig 2603: </div>
2604: <div class="sect1" lang="en">
2605: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2606: <a name="settings-for-creationg-of-binary-packages"></a>6.2. Settings for creation of binary packages</h2></div></div></div>
1.90 ! rillig 2607: <p>See <a href="#build.helpful-targets" title="16.17. Other helpful targets">Section 16.17, “Other helpful targets”</a>.</p>
1.75 rillig 2608: </div>
2609: <div class="sect1" lang="en">
2610: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
2611: <a name="bulkbuild"></a>6.3. Doing a bulk build of all packages</h2></div></div></div>
2612: <p>If you want to get a full set of precompiled binary
1.87 wiz 2613: packages, this section describes how to get them. Beware that
2614: the bulk build will remove all currently installed packages from
2615: your system!</p>
1.75 rillig 2616: <p>Having an FTP server configured either on the
1.87 wiz 2617: machine doing the bulk builds or on a nearby NFS server can help
2618: to make the packages available to other machines that can then
2619: save time by installing only the binary packages. See <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ftpd+8+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ftpd</span>(8)</span></a> for
2620: more information. If you use a remote NFS server's storage, be
2621: sure to not actually compile on NFS storage, as this slows
2622: things down a lot.</p>
1.75 rillig 2623: <div class="sect2" lang="en">
2624: <div class="titlepage"><div><div><h3 class="title">
2625: <a name="binary.configuration"></a>6.3.1. Configuration</h3></div></div></div>
2626: <div class="sect3" lang="en">
2627: <div class="titlepage"><div><div><h4 class="title">
1.76 rillig 2628: <a name="binary.bulk.build.conf"></a>6.3.1.1. <code class="filename">build.conf</code></h4></div></div></div>
2629: <p>The <code class="filename">build.conf</code> file is the main
1.87 wiz 2630: configuration file for bulk builds. You can configure how your
2631: copy of pkgsrc is kept up to date, how the distfiles are
2632: downloaded, how the packages are built and how the report is
2633: generated. You can find an annotated example file in
2634: <code class="filename">pkgsrc/mk/bulk/build.conf-example</code>. To use
2635: it, copy <code class="filename">build.conf-example</code> to
2636: <code class="filename">build.conf</code> and edit it, following the
2637: comments in that file.</p>
1.75 rillig 2638: </div>
2639: <div class="sect3" lang="en">
2640: <div class="titlepage"><div><div><h4 class="title">
2641: <a name="binary.mk.conf"></a>6.3.1.2. /etc/mk.conf</h4></div></div></div>
2642: <p>You may want to set variables in
1.87 wiz 2643: <code class="filename">/etc/mk.conf</code>.
2644: Look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for
2645: details of the default settings. You will want to ensure that
2646: <code class="varname">ACCEPTABLE_LICENSES</code> meet your local policy.
2647: As used in this example, <code class="varname">_ACCEPTABLE=yes</code>
2648: accepts <span class="emphasis"><em>all</em></span> licenses.</p>
2649: <pre class="programlisting">
2650: PACKAGES?= ${_PKGSRCDIR}/packages/${MACHINE_ARCH}
2651: WRKOBJDIR?= /usr/tmp/pkgsrc # build here instead of in pkgsrc
2652: BSDSRCDIR= /usr/src
2653: BSDXSRCDIR= /usr/xsrc # for x11/xservers
2654: OBJHOSTNAME?= yes # use work.`hostname`
2655: FAILOVER_FETCH= yes # insist on the correct checksum
2656: PKG_DEVELOPER?= yes
2657: _ACCEPTABLE= yes
2658: </pre>
1.75 rillig 2659: <p>Some options that are especially useful for bulk builds
2660: can be found at the top lines of the file
1.76 rillig 2661: <code class="filename">mk/bulk/bsd.bulk-pkg.mk</code>. The most useful
1.75 rillig 2662: options of these are briefly described here.</p>
2663: <div class="itemizedlist"><ul type="disc">
2664: <li><p>If you are on a slow machine, you may want to
1.87 wiz 2665: set <code class="varname">USE_BULK_BROKEN_CHECK</code> to
2666: “<span class="quote">no</span>”.</p></li>
1.75 rillig 2667: <li><p>If you are doing bulk builds from a read-only
1.87 wiz 2668: copy of pkgsrc, you have to set <code class="varname">BULKFILESDIR</code>
2669: to the directory where all log files are created. Otherwise the
2670: log files are created in the pkgsrc directory.</p></li>
1.75 rillig 2671: <li><p>Another important variable is
1.87 wiz 2672: <code class="varname">BULK_PREREQ</code>, which is a list of packages that
2673: should be always available while building other
2674: packages.</p></li>
1.75 rillig 2675: </ul></div>
2676: <p>Some other options are scattered in the pkgsrc
2677: infrastructure:</p>
2678: <div class="itemizedlist"><ul type="disc">
2679: <li><p><code class="varname">ALLOW_VULNERABLE_PACKAGES</code>
1.87 wiz 2680: should be set to <code class="literal">yes</code>. The purpose of the bulk
2681: builds is creating binary packages, no matter if they are
2682: vulnerable or not. When uploading the packages to a public
2683: server, the vulnerable packages will be put into a directory of
2684: their own. Leaving this variable unset would prevent the bulk
2685: build system from even trying to build them, so possible
2686: building errors would not show up.</p></li>
1.75 rillig 2687: <li><p><code class="varname">CHECK_FILES</code>
1.87 wiz 2688: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
2689: “<span class="quote">yes</span>” to check that the installed set of files
2690: matches the <code class="filename">PLIST</code>.</p></li>
1.75 rillig 2691: <li><p><code class="varname">CHECK_INTERPRETER</code>
1.87 wiz 2692: (<code class="filename">pkgsrc/mk/bsd.pkg.check.mk</code>) can be set to
2693: “<span class="quote">yes</span>” to check that the installed
2694: “<span class="quote">#!</span>”-scripts will find their
2695: interpreter.</p></li>
1.75 rillig 2696: </ul></div>
2697: </div>
2698: <div class="sect3" lang="en">
2699: <div class="titlepage"><div><div><h4 class="title">
1.76 rillig 2700: <a name="pre-build.local"></a>6.3.1.3. <code class="filename">pre-build.local</code></h4></div></div></div>
1.75 rillig 2701: <p>It is possible to configure the bulk build to perform
1.87 wiz 2702: certain site-specific tasks at the end of the pre-build
2703: stage. If the file
2704: <code class="filename">pre-build.local</code> exists in
2705: <code class="filename">/usr/pkgsrc/mk/bulk</code>, it will be executed
2706: (as a <a href="http://netbsd.gw.com/cgi-bin/man-cgi?sh+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">sh</span>(1)</span></a> script) at the end of the usual pre-build
2707: stage. An example use of
2708: <code class="filename">pre-build.local</code> is to have the line:</p>
1.75 rillig 2709: <pre class="screen">echo "I do not have enough disk space to build this pig." \
1.87 wiz 2710: > misc/openoffice/$BROKENF</pre>
1.75 rillig 2711: <p>to prevent the system from trying to build a particular package
1.87 wiz 2712: which requires nearly 3 GB of disk space.</p>
1.75 rillig 2713: </div>
2714: </div>
2715: <div class="sect2" lang="en">
2716: <div class="titlepage"><div><div><h3 class="title">
2717: <a name="other-environmental-considerations"></a>6.3.2. Other environmental considerations</h3></div></div></div>
1.76 rillig 2718: <p>As <code class="filename">/usr/pkg</code> will be completely
1.87 wiz 2719: deleted at the start of bulk builds, make sure your login
2720: shell is placed somewhere else. Either drop it into
2721: <code class="filename">/usr/local/bin</code> (and adjust your login
2722: shell in the passwd file), or (re-)install it via
2723: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> from <code class="filename">/etc/rc.local</code>, so
2724: you can login after a reboot (remember that your current
2725: process won't die if the package is removed, you just can't
2726: start any new instances of the shell any more). Also, if you
2727: use NetBSD earlier than 1.5, or you still want to use the pkgsrc
2728: version of ssh for some reason, be sure to install ssh before
2729: starting it from <code class="filename">rc.local</code>:</p>
2730: <pre class="programlisting">
2731: ( cd /usr/pkgsrc/security/ssh ; make bulk-install )
2732: if [ -f /usr/pkg/etc/rc.d/sshd ]; then
2733: /usr/pkg/etc/rc.d/sshd
2734: fi
2735: </pre>
1.75 rillig 2736: <p>Not doing so will result in you being not able to log in
1.87 wiz 2737: via ssh after the bulk build is finished or if the machine
2738: gets rebooted or crashes. You have been warned! :)</p>
1.75 rillig 2739: </div>
2740: <div class="sect2" lang="en">
2741: <div class="titlepage"><div><div><h3 class="title">
2742: <a name="operation"></a>6.3.3. Operation</h3></div></div></div>
2743: <p>Make sure you don't need any of the packages still
1.87 wiz 2744: installed.</p>
1.75 rillig 2745: <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
2746: <h3 class="title">Warning</h3>
2747: <p>During the bulk build, <span class="emphasis"><em>all packages will be
1.87 wiz 2748: removed!</em></span></p>
1.75 rillig 2749: </div>
2750: <p>Be sure to remove all other things that might
1.87 wiz 2751: interfere with builds, like some libs installed in
2752: <code class="filename">/usr/local</code>, etc. then become root and type:</p>
2753: <pre class="screen">
2754: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
2755: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build</code></strong>
2756: </pre>
1.75 rillig 2757: <p>If for some reason your last build didn't complete (power
1.87 wiz 2758: failure, system panic, ...), you can continue it by
2759: running:</p>
1.75 rillig 2760: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/build restart</code></strong></pre>
1.87 wiz 2761: <p>At the end of the bulk build, you will get a summary via mail,
2762: and find build logs in the directory specified by
2763: <code class="varname">FTP</code> in the <code class="filename">build.conf</code>
2764: file.</p>
1.75 rillig 2765: </div>
2766: <div class="sect2" lang="en">
2767: <div class="titlepage"><div><div><h3 class="title">
2768: <a name="what-it-does"></a>6.3.4. What it does</h3></div></div></div>
2769: <p>The bulk builds consist of three steps:</p>
2770: <div class="variablelist"><dl>
2771: <dt><span class="term">1. pre-build</span></dt>
1.87 wiz 2772: <dd><p>The script updates your pkgsrc tree via (anon)cvs, then
2773: cleans out any broken distfiles, and removes all
2774: packages installed.</p></dd>
1.75 rillig 2775: <dt><span class="term">2. the bulk build</span></dt>
1.87 wiz 2776: <dd><p>This is basically “<span class="quote">make bulk-package</span>” with
2777: an optimised order in which packages will be
2778: built. Packages that don't require other packages will
2779: be built first, and packages with many dependencies will
2780: be built later.</p></dd>
1.75 rillig 2781: <dt><span class="term">3. post-build</span></dt>
1.87 wiz 2782: <dd><p>Generates a report that's placed in the directory
2783: specified in the <code class="filename">build.conf</code> file
2784: named <code class="filename">broken.html</code>, a short version
2785: of that report will also be mailed to the build's
2786: admin.</p></dd>
1.75 rillig 2787: </dl></div>
1.87 wiz 2788: <p>During the build, a list of broken packages will be compiled
2789: in <code class="filename">/usr/pkgsrc/.broken</code> (or
2790: <code class="filename">.../.broken.${MACHINE}</code> if
2791: <code class="varname">OBJMACHINE</code> is set), individual build logs
2792: of broken builds can be found in the package's
2793: directory. These files are used by the bulk-targets to mark
2794: broken builds to not waste time trying to rebuild them, and
2795: they can be used to debug these broken package builds
2796: later.</p>
1.75 rillig 2797: </div>
2798: <div class="sect2" lang="en">
2799: <div class="titlepage"><div><div><h3 class="title">
2800: <a name="disk-space-requirements"></a>6.3.5. Disk space requirements</h3></div></div></div>
2801: <p>Currently, roughly the following requirements are valid for
1.87 wiz 2802: NetBSD 2.0/i386:</p>
1.75 rillig 2803: <div class="itemizedlist"><ul type="disc">
1.87 wiz 2804: <li><p>10 GB - distfiles (NFS ok)</p></li>
2805: <li><p>8 GB - full set of all binaries (NFS ok)</p></li>
2806: <li><p>5 GB - temp space for compiling (local disk recommended)</p></li>
2807: </ul></div>
2808: <p>Note that all pkgs will be de-installed as soon as they are
2809: turned into a binary package, and that sources are removed,
2810: so there is no excessively huge demand to disk
2811: space. Afterwards, if the package is needed again, it will
2812: be installed via <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> instead of building again, so
2813: there are no cycles wasted by recompiling.</p>
1.75 rillig 2814: </div>
2815: <div class="sect2" lang="en">
2816: <div class="titlepage"><div><div><h3 class="title">
2817: <a name="setting-up-a-sandbox"></a>6.3.6. Setting up a sandbox for chrooted builds</h3></div></div></div>
1.87 wiz 2818: <p>If you don't want all the packages nuked from a machine
2819: (rendering it useless for anything but pkg compiling), there
2820: is the possibility of doing the package bulk build inside a
2821: chroot environment.</p>
2822: <p>The first step is to set up a chroot sandbox,
2823: e.g. <code class="filename">/usr/sandbox</code>. This can be done by
2824: using null mounts, or manually.</p>
2825: <p>There is a shell script called
2826: <code class="filename">pkgsrc/mk/bulk/mksandbox</code> which will set
2827: up the sandbox environment using null mounts. It will also
2828: create a script called <code class="filename">sandbox</code> in the
2829: root of the sandbox environment, which will allow the null
2830: mounts to be activated using the <span><strong class="command">sandbox
2831: mount</strong></span> command and deactivated using the
2832: <span><strong class="command">sandbox umount</strong></span> command.</p>
2833: <p>To set up a sandbox environment by hand, after extracting all
2834: the sets from a NetBSD installation or doing a <span><strong class="command">make
2835: distribution DESTDIR=/usr/sandbox</strong></span> in
2836: <code class="filename">/usr/src/etc</code>, be sure the following items
2837: are present and properly configured:</p>
1.75 rillig 2838: <div class="procedure"><ol type="1">
2839: <li>
2840: <p>Kernel</p>
2841: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /netbsd /usr/sandbox</code></strong></pre>
2842: </li>
2843: <li>
1.76 rillig 2844: <p><code class="filename">/dev/*</code></p>
1.75 rillig 2845: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/dev ; sh MAKEDEV all</code></strong></pre>
2846: </li>
2847: <li>
1.76 rillig 2848: <p><code class="filename">/etc/resolv.conf</code> (for <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/smtpd/README.html" target="_top"><code class="filename">security/smtpd</code></a> and mail):</p>
1.75 rillig 2849: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/resolv.conf /usr/sandbox/etc</code></strong></pre>
2850: </li>
2851: <li>
2852: <p>Working(!) mail config (hostname, sendmail.cf):</p>
2853: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cp /etc/mail/sendmail.cf /usr/sandbox/etc/mail</code></strong></pre>
2854: </li>
2855: <li>
1.76 rillig 2856: <p><code class="filename">/etc/localtime</code> (for <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/smtpd/README.html" target="_top"><code class="filename">security/smtpd</code></a>):</p>
1.75 rillig 2857: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -sf /usr/share/zoneinfo/UTC /usr/sandbox/etc/localtime</code></strong></pre>
2858: </li>
2859: <li>
1.76 rillig 2860: <p><code class="filename">/usr/src</code> (system sources,
1.89 rillig 2861: e. g. for <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/sysutils/aperture/README.html" target="_top"><code class="filename">sysutils/aperture</code></a>):</p>
1.75 rillig 2862: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>ln -s ../disk1/cvs .</code></strong>
1.87 wiz 2863: <code class="prompt">#</code> <strong class="userinput"><code>ln -s cvs/src-2.0 src</code></strong></pre>
1.75 rillig 2864: </li>
2865: <li>
1.76 rillig 2866: <p>Create <code class="filename">/var/db/pkg</code> (not part of default install):</p>
1.75 rillig 2867: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/var/db/pkg</code></strong></pre>
2868: </li>
2869: <li>
1.76 rillig 2870: <p>Create <code class="filename">/usr/pkg</code> (not part of default install):</p>
1.75 rillig 2871: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>mkdir /usr/sandbox/usr/pkg</code></strong></pre>
2872: </li>
2873: <li>
2874: <p>Checkout pkgsrc via cvs into
1.87 wiz 2875: <code class="filename">/usr/sandbox/usr/pkgsrc</code>:</p>
2876: <pre class="screen">
2877: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr</code></strong>
2878: <code class="prompt">#</code> <strong class="userinput"><code>cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -d -P pkgsrc</code></strong>
2879: </pre>
1.75 rillig 2880: <p>Do not mount/link this to the copy of your pkgsrc tree
1.87 wiz 2881: you do development in, as this will likely cause problems!</p>
1.75 rillig 2882: </li>
2883: <li><p>Make
1.87 wiz 2884: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code> and
2885: <code class="filename">.../distfiles</code> point somewhere
2886: appropriate. NFS- and/or nullfs-mounts may come in handy!</p></li>
1.76 rillig 2887: <li><p>Edit <code class="filename">/etc/mk.conf</code>, see <a href="#binary.mk.conf" title="6.3.1.2. /etc/mk.conf">Section 6.3.1.2, “/etc/mk.conf”</a>.</p></li>
2888: <li><p>Adjust <code class="filename">mk/bulk/build.conf</code> to suit your needs.</p></li>
1.75 rillig 2889: </ol></div>
2890: <p>When the chroot sandbox is set up, you can start
1.87 wiz 2891: the build with the following steps:</p>
2892: <pre class="screen">
2893: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
2894: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-build</code></strong>
2895: </pre>
2896: <p>This will just jump inside the sandbox and start building. At
2897: the end of the build, mail will be sent with the results of
2898: the build. Created binary pkgs will be in
2899: <code class="filename">/usr/sandbox/usr/pkgsrc/packages</code>
2900: (wherever that points/mounts to/from).</p>
1.75 rillig 2901: </div>
2902: <div class="sect2" lang="en">
2903: <div class="titlepage"><div><div><h3 class="title">
2904: <a name="building-a-partial-set"></a>6.3.7. Building a partial set of packages</h3></div></div></div>
1.87 wiz 2905: <p>In addition to building a complete set of all packages in
2906: pkgsrc, the <code class="filename">pkgsrc/mk/bulk/build</code> script
2907: may be used to build a subset of the packages contained in
2908: pkgsrc. By setting <code class="varname">SPECIFIC_PKGS</code>
2909: in <code class="filename">/etc/mk.conf</code>, the variables</p>
1.75 rillig 2910: <div class="itemizedlist"><ul type="disc">
2911: <li><p>SITE_SPECIFIC_PKGS</p></li>
2912: <li><p>HOST_SPECIFIC_PKGS</p></li>
2913: <li><p>GROUP_SPECIFIC_PKGS</p></li>
2914: <li><p>USER_SPECIFIC_PKGS</p></li>
2915: </ul></div>
1.87 wiz 2916: <p>will define the set of packages which should be built.
2917: The bulk build code will also include any packages which are
2918: needed as dependencies for the explicitly listed packages.</p>
2919: <p>One use of this is to do a bulk build with
2920: <code class="varname">SPECIFIC_PKGS</code> in a chroot sandbox
2921: periodically to have a complete set of the binary packages
2922: needed for your site available without the overhead of
2923: building extra packages that are not needed.</p>
1.75 rillig 2924: </div>
2925: <div class="sect2" lang="en">
2926: <div class="titlepage"><div><div><h3 class="title">
2927: <a name="bulk-upload"></a>6.3.8. Uploading results of a bulk build</h3></div></div></div>
1.87 wiz 2928: <p>This section describes how pkgsrc developers can upload binary
2929: pkgs built by bulk builds to ftp.NetBSD.org.</p>
2930: <p>If you would like to automatically create checksum files for the
2931: binary packages you intend to upload, remember to set
2932: <code class="varname">MKSUMS=yes</code> in your
2933: <code class="filename">mk/bulk/build.conf</code>.</p>
2934: <p>If you would like to PGP sign the checksum files (highly
2935: recommended!), remember to set
2936: <code class="varname">SIGN_AS=username@NetBSD.org</code> in your
2937: <code class="filename">mk/bulk/build.conf</code>. This will prompt you for
2938: your GPG password to sign the files before uploading everything.</p>
2939: <p>Then, make sure that you have <code class="varname">RSYNC_DST</code>
2940: set properly in your <code class="filename">mk/bulk/build.conf</code>
2941: file, i.e. adjust it to something like one of the following:</p>
1.75 rillig 2942: <pre class="screen">RSYNC_DST=ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload </pre>
2943: <p>Please use appropriate values for "pkgsrc-200xQy",
1.87 wiz 2944: "NetBSD-a.b.c" and "arch" here. If your login on ftp.NetBSD.org
2945: is different from your local login, write your login directly
2946: into the variable, e.g. my local account is "feyrer", but for my
2947: login "hubertf", I use:</p>
2948: <pre class="screen">RSYNC_DST=hubertf@ftp.NetBSD.org:/pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload</pre>
2949: <p>A separate <code class="filename">upload</code> directory is used
2950: here to allow "closing" the directory during upload. To do
2951: so, run the following command on ftp.NetBSD.org next:</p>
1.75 rillig 2952: <pre class="screen">nbftp% <strong class="userinput"><code>mkdir -p -m 750 /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch/upload</code></strong></pre>
1.87 wiz 2953: <p>Please note that <code class="filename">/pub/NetBSD/packages</code> is
2954: only appropriate for packages for the NetBSD operating
2955: system. Binary packages for other operating systems should go
2956: into <code class="filename">/pub/pkgsrc</code>.</p>
2957: <p>Before uploading the binary pkgs, ssh authentication needs
2958: to be set up. This example shows how to set up temporary keys
2959: for the root account <span class="emphasis"><em>inside the sandbox</em></span>
2960: (assuming that no keys should be present there usually):</p>
2961: <pre class="screen">
2962: <code class="prompt">#</code> <strong class="userinput"><code>chroot /usr/sandbox</code></strong>
1.75 rillig 2963: chroot-<code class="prompt">#</code> <strong class="userinput"><code>rm $HOME/.ssh/id-dsa*</code></strong>
2964: chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh-keygen -t dsa</code></strong>
1.87 wiz 2965: chroot-<code class="prompt">#</code> <strong class="userinput"><code>cat $HOME/.ssh/id-dsa.pub</code></strong>
2966: </pre>
2967: <p>Now take the output of <code class="filename">id-dsa.pub</code> and
2968: append it to your <code class="filename">~/.ssh/authorized_keys</code>
2969: file on ftp.NetBSD.org. You can remove the key after the
2970: upload is done!</p>
2971: <p>Next, test if your ssh connection really works:</p>
1.75 rillig 2972: <pre class="screen">chroot-<code class="prompt">#</code> <strong class="userinput"><code>ssh ftp.NetBSD.org date</code></strong> </pre>
1.87 wiz 2973: <p>Use "-l yourNetBSDlogin" here as appropriate!</p>
2974: <p>Now after all this works, you can exit the sandbox and start
2975: the upload:</p>
2976: <pre class="screen">
2977: chroot-<code class="prompt">#</code> <strong class="userinput"><code>exit</code></strong>
1.75 rillig 2978: <code class="prompt">#</code> <strong class="userinput"><code>cd /usr/sandbox/usr/pkgsrc</code></strong>
1.87 wiz 2979: <code class="prompt">#</code> <strong class="userinput"><code>sh mk/bulk/do-sandbox-upload</code></strong>
2980: </pre>
2981: <p>The upload process may take quite some time. Use <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ls+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ls</span>(1)</span></a> or
2982: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?du+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">du</span>(1)</span></a> on the FTP server to monitor progress of the
2983: upload. The upload script will take care of not uploading
2984: restricted packages and putting vulnerable packages into the
2985: <code class="filename">vulnerable</code> subdirectory.</p>
2986: <p>After the upload has ended, first thing is to revoke ssh access:</p>
1.75 rillig 2987: <pre class="screen">nbftp% <strong class="userinput"><code>vi ~/.ssh/authorized_keys</code></strong>
1.87 wiz 2988: Gdd:x! </pre>
2989: <p>Use whatever is needed to remove the key you've entered
2990: before! Last, move the uploaded packages out of the
2991: <code class="filename">upload</code> directory to have them accessible
2992: to everyone:</p>
2993: <pre class="screen">
2994: nbftp% <strong class="userinput"><code>cd /pub/NetBSD/packages/pkgsrc-200xQy/NetBSD-a.b.c/arch</code></strong>
1.75 rillig 2995: nbftp% <strong class="userinput"><code>mv upload/* .</code></strong>
2996: nbftp% <strong class="userinput"><code>rmdir upload</code></strong>
1.87 wiz 2997: nbftp% <strong class="userinput"><code>chmod 755 .</code></strong>
2998: </pre>
1.75 rillig 2999: </div>
3000: </div>
3001: <div class="sect1" lang="en">
3002: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
3003: <a name="creating-cdroms"></a>6.4. Creating a multiple CD-ROM packages collection</h2></div></div></div>
1.87 wiz 3004: <p>After your pkgsrc bulk-build has completed, you may wish to
3005: create a CD-ROM set of the resulting binary packages to assist
3006: in installing packages on other machines. The
3007: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/cdpack/README.html" target="_top"><code class="filename">pkgtools/cdpack</code></a> package provides
3008: a simple tool for creating the ISO 9660 images.
3009: <span><strong class="command">cdpack</strong></span> arranges the packages on the CD-ROMs in a
3010: way that keeps all the dependencies for a given package on the same
3011: CD as that package.</p>
1.75 rillig 3012: <div class="sect2" lang="en">
3013: <div class="titlepage"><div><div><h3 class="title">
3014: <a name="cdpack-example"></a>6.4.1. Example of cdpack</h3></div></div></div>
1.87 wiz 3015: <p>Complete documentation for cdpack is found in the cdpack(1)
3016: man page. The following short example assumes that the binary
3017: packages are left in
3018: <code class="filename">/usr/pkgsrc/packages/All</code> and that
3019: sufficient disk space exists in <code class="filename">/u2</code> to
3020: hold the ISO 9660 images.</p>
3021: <pre class="screen">
3022: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /u2/images</code></strong>
1.75 rillig 3023: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add /usr/pkgsrc/packages/All/cdpack</code></strong>
1.87 wiz 3024: <code class="prompt">#</code> <strong class="userinput"><code>cdpack /usr/pkgsrc/packages/All /u2/images</code></strong>
3025: </pre>
3026: <p>If you wish to include a common set of files
3027: (<code class="filename">COPYRIGHT</code>, <code class="filename">README</code>,
3028: etc.) on each CD in the collection, then you need to create a
3029: directory which contains these files. e.g.</p>
3030: <pre class="screen">
3031: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common</code></strong>
1.75 rillig 3032: <code class="prompt">#</code> <strong class="userinput"><code>echo "This is a README" > /tmp/common/README</code></strong>
3033: <code class="prompt">#</code> <strong class="userinput"><code>echo "Another file" > /tmp/common/COPYING</code></strong>
3034: <code class="prompt">#</code> <strong class="userinput"><code>mkdir /tmp/common/bin</code></strong>
3035: <code class="prompt">#</code> <strong class="userinput"><code>echo "#!/bin/sh" > /tmp/common/bin/myscript</code></strong>
3036: <code class="prompt">#</code> <strong class="userinput"><code>echo "echo Hello world" >> /tmp/common/bin/myscript</code></strong>
1.87 wiz 3037: <code class="prompt">#</code> <strong class="userinput"><code>chmod 755 /tmp/common/bin/myscript</code></strong>
3038: </pre>
1.75 rillig 3039: <p>Now create the images:</p>
3040: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images</code></strong></pre>
1.76 rillig 3041: <p>Each image will contain <code class="filename">README</code>,
1.87 wiz 3042: <code class="filename">COPYING</code>, and <code class="filename">bin/myscript</code>
3043: in their root directories.</p>
1.75 rillig 3044: </div>
3045: </div>
3046: </div>
3047: <div class="chapter" lang="en">
3048: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 3049: <a name="files"></a>Chapter 7. Directory layout of the installed files</h2></div></div></div>
! 3050: <div class="toc">
! 3051: <p><b>Table of Contents</b></p>
! 3052: <dl>
! 3053: <dt><span class="sect1"><a href="#files.localbase">7.1. File system layout in <code class="literal">${PREFIX}</code></a></span></dt>
! 3054: <dt><span class="sect1"><a href="#files.varbase">7.2. File system layout in <code class="literal">${VARBASE}</code></a></span></dt>
! 3055: </dl>
! 3056: </div>
! 3057: <p>The files that are installed by pkgsrc are organized in a way that
! 3058: is similar to what you find in the <code class="filename">/usr</code> directory
! 3059: of the base system. But some details are different. This is because
! 3060: pkgsrc initially came from FreeBSD and had adopted its file system
! 3061: hierarchy. Later it was largely influenced by NetBSD. But no matter
! 3062: which operating system you are using pkgsrc with, you can expect the
! 3063: same layout for pkgsrc.</p>
! 3064: <p>There are mainly three root directories for pkgsrc:</p>
! 3065: <div class="itemizedlist"><ul type="disc">
! 3066: <li><p><code class="varname">LOCALBASE</code> corresponds to the
! 3067: <code class="filename">/usr</code> directory in the base system. It is the
! 3068: “<span class="quote">main</span>” directory where the files are installed and contains
! 3069: the well-known subdirectories like <code class="filename">bin</code>,
! 3070: <code class="filename">include</code>, <code class="filename">lib</code>,
! 3071: <code class="filename">share</code> and
! 3072: <code class="filename">sbin</code>.</p></li>
! 3073: <li><p><code class="varname">VARBASE</code> corresponds to
! 3074: <code class="filename">/var</code> in the base system. Some programs (especially
! 3075: games, network daemons) need write access to it during normal
! 3076: operation.</p></li>
! 3077: <li><p><code class="varname">PKG_SYSCONFDIR</code> corresponds to
! 3078: <code class="filename">/etc</code> in the base system. It contains configuration
! 3079: files of the packages, as well as pkgsrc's <code class="filename">mk.conf</code>
! 3080: itself.</p></li>
! 3081: </ul></div>
! 3082: <div class="sect1" lang="en">
! 3083: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 3084: <a name="files.localbase"></a>7.1. File system layout in <code class="literal">${PREFIX}</code></h2></div></div></div>
! 3085: <p>The following directories exist in a typical pkgsrc installation
! 3086: in <code class="filename">${PREFIX}</code>.</p>
! 3087: <div class="variablelist"><dl>
! 3088: <dt><span class="term"><code class="filename">bin</code></span></dt>
! 3089: <dd><p>Contains executable programs that are intended to be
! 3090: directly used by the end user.</p></dd>
! 3091: <dt><span class="term"><code class="filename">emul</code></span></dt>
! 3092: <dd><p>Contains files for the emulation layers of various other
! 3093: operating systems, especially for
! 3094: NetBSD.</p></dd>
! 3095: <dt><span class="term"><code class="filename">etc</code> (the usual location of
! 3096: <code class="filename">${PKG_SYSCONFDIR}</code>)</span></dt>
! 3097: <dd><p>Contains
! 3098: the configuration files.</p></dd>
! 3099: <dt><span class="term"><code class="filename">include</code></span></dt>
! 3100: <dd><p>Contains headers for the C and C++ programming
! 3101: languages.</p></dd>
! 3102: <dt><span class="term"><code class="filename">info</code></span></dt>
! 3103: <dd><p>Contains GNU info files of various
! 3104: packages.</p></dd>
! 3105: <dt><span class="term"><code class="filename">lib</code></span></dt>
! 3106: <dd><p>Contains shared and static
! 3107: libraries.</p></dd>
! 3108: <dt><span class="term"><code class="filename">libdata</code></span></dt>
! 3109: <dd><p>Contains data files that don't change after
! 3110: installation. Other data files belong into
! 3111: <code class="filename">${VARBASE}</code>.</p></dd>
! 3112: <dt><span class="term"><code class="filename">libexec</code></span></dt>
! 3113: <dd><p>Contains programs that are not intended to be used by
! 3114: end users, such as helper programs or network
! 3115: daemons.</p></dd>
! 3116: <dt><span class="term"><code class="filename">libexec/cgi-bin</code></span></dt>
! 3117: <dd><p>Contains programs that are intended to be executed as
! 3118: CGI scripts by a web server.</p></dd>
! 3119: <dt><span class="term"><code class="filename">man</code> (the usual value of
! 3120: <code class="filename">${PKGMANDIR}</code>)</span></dt>
! 3121: <dd><p>Contains brief
! 3122: documentation in form of manual pages.</p></dd>
! 3123: <dt><span class="term"><code class="filename">sbin</code></span></dt>
! 3124: <dd><p>Contains programs that are intended to be used only by
! 3125: the super-user.</p></dd>
! 3126: <dt><span class="term"><code class="filename">share</code></span></dt>
! 3127: <dd><p>Contains platform-independent data files that don't
! 3128: change after installation.</p></dd>
! 3129: <dt><span class="term"><code class="filename">share/doc</code></span></dt>
! 3130: <dd><p>Contains documentation files provided by the
! 3131: packages.</p></dd>
! 3132: <dt><span class="term"><code class="filename">share/examples</code></span></dt>
! 3133: <dd><p>Contains example files provided by the packages. Among
! 3134: others, the original configuration files are saved here and copied to
! 3135: <code class="filename">${PKG_SYSCONFDIR}</code> during
! 3136: installation.</p></dd>
! 3137: <dt><span class="term"><code class="filename">share/examples/rc.d</code></span></dt>
! 3138: <dd><p>Contains the original files for rc.d
! 3139: scripts.</p></dd>
! 3140: <dt><span class="term"><code class="filename">var</code> (the usual location of
! 3141: <code class="filename">${VARBASE}</code>)</span></dt>
! 3142: <dd><p>Contains files
! 3143: that may be modified after
! 3144: installation.</p></dd>
! 3145: </dl></div>
! 3146: </div>
! 3147: <div class="sect1" lang="en">
! 3148: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
! 3149: <a name="files.varbase"></a>7.2. File system layout in <code class="literal">${VARBASE}</code></h2></div></div></div>
! 3150: <div class="variablelist"><dl>
! 3151: <dt><span class="term"><code class="filename">db/pkg</code> (the usual location of
! 3152: <code class="filename">${PKG_DBDIR}</code>)</span></dt>
! 3153: <dd><p>Contains
! 3154: information about the currently installed
! 3155: packages.</p></dd>
! 3156: <dt><span class="term"><code class="filename">games</code></span></dt>
! 3157: <dd><p>Contains highscore
! 3158: files.</p></dd>
! 3159: <dt><span class="term"><code class="filename">log</code></span></dt>
! 3160: <dd><p>Contains log files.</p></dd>
! 3161: <dt><span class="term"><code class="filename">run</code></span></dt>
! 3162: <dd><p>Contains informational files about daemons that are
! 3163: currently running.</p></dd>
! 3164: </dl></div>
! 3165: </div>
! 3166: </div>
! 3167: <div class="chapter" lang="en">
! 3168: <div class="titlepage"><div><div><h2 class="title">
! 3169: <a name="faq"></a>Chapter 8. Frequently Asked Questions</h2></div></div></div>
1.75 rillig 3170: <div class="toc">
3171: <p><b>Table of Contents</b></p>
3172: <dl>
1.90 ! rillig 3173: <dt><span class="sect1"><a href="#mailing-list-pointers">8.1. Are there any mailing lists for pkg-related discussion?</a></span></dt>
! 3174: <dt><span class="sect1"><a href="#pkgviews-docs">8.2. Where's the pkgviews documentation?</a></span></dt>
! 3175: <dt><span class="sect1"><a href="#faq-pkgtools">8.3. Utilities for package management (pkgtools)</a></span></dt>
! 3176: <dt><span class="sect1"><a href="#non-root-pkgsrc">8.4. How to use pkgsrc as non-root</a></span></dt>
! 3177: <dt><span class="sect1"><a href="#resume-transfers">8.5. How to resume transfers when fetching distfiles?</a></span></dt>
! 3178: <dt><span class="sect1"><a href="#XFree86-from-pkgsrc">8.6. How can I install/use XFree86 from pkgsrc?</a></span></dt>
! 3179: <dt><span class="sect1"><a href="#x.org-from-pkgsrc">8.7. How can I install/use X.org from pkgsrc?</a></span></dt>
! 3180: <dt><span class="sect1"><a href="#fetch-behind-firewall">8.8. How to fetch files from behind a firewall</a></span></dt>
! 3181: <dt><span class="sect1"><a href="#passive-ftp">8.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</a></span></dt>
! 3182: <dt><span class="sect1"><a href="#fetching-all-distfiles">8.10. How to fetch all distfiles at once</a></span></dt>
! 3183: <dt><span class="sect1"><a href="#tmac.andoc-missing">8.11. What does “<span class="quote">Don't know how to make
1.75 rillig 3184: /usr/share/tmac/tmac.andoc</span>” mean?</a></span></dt>
1.90 ! rillig 3185: <dt><span class="sect1"><a href="#bsd.own.mk-missing">8.12. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</a></span></dt>
! 3186: <dt><span class="sect1"><a href="#using-sudo-with-pkgsrc">8.13. Using 'sudo' with pkgsrc</a></span></dt>
! 3187: <dt><span class="sect1"><a href="#faq.conf">8.14. How do I change the location of configuration files?</a></span></dt>
! 3188: <dt><span class="sect1"><a href="#audit-packages">8.15. Automated security checks</a></span></dt>
! 3189: <dt><span class="sect1"><a href="#ufaq-cflags">8.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</a></span></dt>
! 3190: <dt><span class="sect1"><a href="#ufaq-fail">8.17. A package does not build. What shall I do?</a></span></dt>
! 3191: <dt><span class="sect1"><a href="#faq.rcs-conflicts">8.18. What does “<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>” mean?</a></span></dt>
! 3192: <dt><span class="sect1"><a href="#too-much-time">8.19. I have a little time to kill. What shall I do?</a></span></dt>
1.75 rillig 3193: </dl>
3194: </div>
3195: <p>This section contains hints, tips & tricks on special things in
3196: pkgsrc that we didn't find a better place for in the previous chapters, and
3197: it contains items for both pkgsrc users and developers.</p>
3198: <div class="sect1" lang="en">
3199: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3200: <a name="mailing-list-pointers"></a>8.1. Are there any mailing lists for pkg-related discussion?</h2></div></div></div>
1.75 rillig 3201: <p>The following mailing lists may be of interest to pkgsrc users:</p>
3202: <div class="itemizedlist"><ul type="disc">
1.78 rillig 3203: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-users" target="_top">pkgsrc-users</a>:
3204: This is a general purpose list for most issues regarding
3205: pkgsrc, regardless of platform, e.g. soliciting user help
3206: for pkgsrc configuration, unexpected build failures, using
3207: particular packages, upgrading pkgsrc installations,
3208: questions regarding the pkgsrc release branches, etc. General announcements or
3209: proposals for changes that impact the pkgsrc user community,
3210: e.g. major infrastructure changes, new features, package
3211: removals, etc., may also be posted.</p></li>
1.75 rillig 3212: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bulk" target="_top">pkgsrc-bulk</a>:
3213: A list where the results of pkgsrc bulk builds are sent and
3214: discussed.</p></li>
3215: <li><p><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-changes" target="_top">pkgsrc-changes</a>:
3216: This list is for those who are interested in getting a
3217: commit message for every change committed to pkgsrc. It is
3218: also available in digest form, meaning one daily message
3219: containing all commit messages for changes to the package
3220: source tree in that 24 hour period.</p></li>
3221: </ul></div>
3222: <p>To subscribe, do:</p>
3223: <pre class="programlisting">
3224: <code class="prompt">%</code> echo subscribe <em class="replaceable"><code>listname</code></em> | mail majordomo@NetBSD.org
3225: </pre>
3226: <p>Archives for all these mailing lists are available from
3227: <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>.</p>
3228: </div>
3229: <div class="sect1" lang="en">
3230: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3231: <a name="pkgviews-docs"></a>8.2. Where's the pkgviews documentation?</h2></div></div></div>
1.75 rillig 3232: <p>Pkgviews is tightly integrated with buildlink. You can find a
3233: pkgviews User's guide in
1.76 rillig 3234: <code class="filename">pkgsrc/mk/buildlink3/PKGVIEWS_UG</code>.</p>
1.75 rillig 3235: </div>
3236: <div class="sect1" lang="en">
3237: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3238: <a name="faq-pkgtools"></a>8.3. Utilities for package management (pkgtools)</h2></div></div></div>
1.80 rillig 3239: <p>The directory <code class="filename">pkgsrc/pkgtools</code> contains
1.75 rillig 3240: a number of useful utilities for both users and developers of pkgsrc. This
3241: section attempts only to make the reader aware of the utilities and when
3242: they might be useful, and not to duplicate the documentation that comes
3243: with each package.</p>
3244: <p>Utilities used by pkgsrc (automatically installed when needed):</p>
1.76 rillig 3245: <div class="itemizedlist"><ul type="disc"><li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/x11-links/README.html" target="_top"><code class="filename">pkgtools/x11-links</code></a>:
1.75 rillig 3246: Symlinks for use by buildlink.</p></li></ul></div>
3247: <p>OS tool augmentation (automatically installed when needed):</p>
3248: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3249: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/digest/README.html" target="_top"><code class="filename">pkgtools/digest</code></a>:
1.75 rillig 3250: Calculates various kinds of checksums (including SHA1).</p></li>
1.76 rillig 3251: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/libnbcompat/README.html" target="_top"><code class="filename">pkgtools/libnbcompat</code></a>:
1.75 rillig 3252: Compatibility library for pkgsrc tools.</p></li>
1.76 rillig 3253: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/mtree/README.html" target="_top"><code class="filename">pkgtools/mtree</code></a>: Installed on
1.87 wiz 3254: non-BSD systems due to lack of native mtree.</p></li>
1.76 rillig 3255: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a>:
1.75 rillig 3256: Up-to-date replacement for
1.76 rillig 3257: <code class="filename">/usr/sbin/pkg_install</code>, or for use on operating
1.75 rillig 3258: systems where pkg_install is not present.</p></li>
3259: </ul></div>
3260: <p>Utilities used by pkgsrc (not automatically installed):</p>
3261: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3262: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_tarup/README.html" target="_top"><code class="filename">pkgtools/pkg_tarup</code></a>:
1.75 rillig 3263: Create a binary package from an
3264: already-installed package. Used by <span><strong class="command">make replace</strong></span> to
3265: save the old package.</p></li>
1.76 rillig 3266: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/dfdisk/README.html" target="_top"><code class="filename">pkgtools/dfdisk</code></a>:
1.75 rillig 3267: Adds extra functionality to pkgsrc, allowing it to fetch distfiles
3268: from multiple locations. It currently supports the following
3269: methods: multiple CD-ROMs and network FTP/HTTP connections.</p></li>
1.76 rillig 3270: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a>: Put X11
1.75 rillig 3271: packages someplace else (enabled by default).</p></li>
1.76 rillig 3272: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/cpuflags/README.html" target="_top"><code class="filename">devel/cpuflags</code></a>: Determine the
1.75 rillig 3273: best compiler flags to optimise code for your current CPU and
3274: compiler.</p></li>
3275: </ul></div>
3276: <p>Utilities for keeping track of installed packages, being up to date,
3277: etc:</p>
3278: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3279: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_chk/README.html" target="_top"><code class="filename">pkgtools/pkg_chk</code></a>: Reports on
1.75 rillig 3280: packages whose installed versions do not match the latest pkgsrc
3281: entries.</p></li>
1.76 rillig 3282: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdep/README.html" target="_top"><code class="filename">pkgtools/pkgdep</code></a>: Makes
1.75 rillig 3283: dependency graphs of packages, to aid in choosing a strategy for
3284: updating.</p></li>
1.76 rillig 3285: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdepgraph/README.html" target="_top"><code class="filename">pkgtools/pkgdepgraph</code></a>: Makes
3286: graphs from the output of <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdep/README.html" target="_top"><code class="filename">pkgtools/pkgdep</code></a> (uses graphviz).</p></li>
3287: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>: The
1.75 rillig 3288: pkglint(1) program checks a pkgsrc entry for errors, lintpkgsrc(1)
3289: does various checks on the complete pkgsrc system.</p></li>
1.76 rillig 3290: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgsurvey/README.html" target="_top"><code class="filename">pkgtools/pkgsurvey</code></a>: Report what
1.75 rillig 3291: packages you have installed.</p></li>
3292: </ul></div>
3293: <p>Utilities for people maintaining or creating individual packages:</p>
3294: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3295: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a>: Automate
1.75 rillig 3296: making and maintaining patches for a package (includes pkgdiff,
3297: pkgvi, mkpatches, etc.).</p></li>
1.76 rillig 3298: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/rpm2pkg/README.html" target="_top"><code class="filename">pkgtools/rpm2pkg</code></a>,
3299: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a>: Aids in
1.75 rillig 3300: converting to pkgsrc.</p></li>
1.76 rillig 3301: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/gensolpkg/README.html" target="_top"><code class="filename">pkgtools/gensolpkg</code></a>: Convert
1.75 rillig 3302: pkgsrc to a Solaris package.</p></li>
3303: </ul></div>
3304: <p>Utilities for people maintaining pkgsrc (or: more obscure pkg
3305: utilities)</p>
3306: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3307: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_comp/README.html" target="_top"><code class="filename">pkgtools/pkg_comp</code></a>: Build
1.75 rillig 3308: packages in a chrooted area.</p></li>
1.76 rillig 3309: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/libkver/README.html" target="_top"><code class="filename">pkgtools/libkver</code></a>: Spoof
1.75 rillig 3310: kernel version for chrooted cross builds.</p></li>
3311: </ul></div>
3312: </div>
3313: <div class="sect1" lang="en">
3314: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3315: <a name="non-root-pkgsrc"></a>8.4. How to use pkgsrc as non-root</h2></div></div></div>
1.75 rillig 3316: <p>If you want to use pkgsrc as non-root user, you can set some
3317: variables to make pkgsrc work under these conditions. At the very least,
3318: you need to set <code class="varname">UNPRIVILEGED</code> to “<span class="quote">yes</span>”; this
3319: will turn on unprivileged mode and set multiple related variables to allow
3320: installation of packages as non-root.</p>
3321: <p>In case the defaults are not enough, you may want to tune some other
3322: variables used. For example, if the automatic user/group detection leads
3323: to incorrect values (or not the ones you would like to use), you can change
3324: them by setting <code class="varname">UNPRIVILEGED_USER</code> and
3325: <code class="varname">UNPRIVILEGED_GROUP</code> respectively.</p>
3326: <p>As regards bootstrapping, please note that the
3327: <span><strong class="command">bootstrap</strong></span> script will ease non-root configuration when
3328: given the “<span class="quote">--ignore-user-check</span>” flag, as it will choose and
1.76 rillig 3329: use multiple default directories under <code class="filename">~/pkg</code> as the
1.75 rillig 3330: installation targets. These directories can be overriden by the
3331: “<span class="quote">--prefix</span>” flag provided by the script, as well as some others
3332: that allow finer tuning of the tree layout.</p>
3333: </div>
3334: <div class="sect1" lang="en">
3335: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3336: <a name="resume-transfers"></a>8.5. How to resume transfers when fetching distfiles?</h2></div></div></div>
1.75 rillig 3337: <p>By default, resuming transfers in pkgsrc is disabled, but you can
3338: enable this feature by adding the option
3339: <code class="varname">PKG_RESUME_TRANSFERS=YES</code> into
1.76 rillig 3340: <code class="filename">/etc/mk.conf</code>. If, during a fetch step, an incomplete
1.75 rillig 3341: distfile is found, pkgsrc will try to resume it.</p>
3342: <p>You can also
3343: use a different program than the default <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ftp+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ftp</span>(1)</span></a> by changing the
3344: <code class="varname">FETCH_CMD</code> variable. Don't forget to set
3345: <code class="varname">FETCH_RESUME_ARGS</code> and
3346: <code class="varname">FETCH_OUTPUT_ARGS</code> if you are not using default
3347: values.</p>
3348: <p>For example, if you want to use
1.76 rillig 3349: <code class="filename">wget</code> to resume downloads, you'll have to use something
1.75 rillig 3350: like:</p>
3351: <pre class="programlisting">
3352: FETCH_CMD= wget
3353: FETCH_BEFORE_ARGS= --passive-ftp
3354: FETCH_RESUME_ARGS= -c
3355: FETCH_OUTPUT_ARGS= -O
1.1 grant 3356: </pre>
1.75 rillig 3357: </div>
3358: <div class="sect1" lang="en">
3359: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3360: <a name="XFree86-from-pkgsrc"></a>8.6. How can I install/use XFree86 from pkgsrc?</h2></div></div></div>
1.75 rillig 3361: <p>If you want to use XFree86 from pkgsrc instead of your system's own
1.76 rillig 3362: X11 (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>,
1.75 rillig 3363: ...), you will have to add the following line into
1.76 rillig 3364: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 3365: <pre class="programlisting">
3366: X11_TYPE=XFree86
1.1 grant 3367: </pre>
1.75 rillig 3368: </div>
3369: <div class="sect1" lang="en">
3370: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3371: <a name="x.org-from-pkgsrc"></a>8.7. How can I install/use X.org from pkgsrc?</h2></div></div></div>
1.75 rillig 3372: <p>If you want to use X.org from pkgsrc instead of your system's own X11
1.76 rillig 3373: (<code class="filename">/usr/X11R6</code>, <code class="filename">/usr/openwin</code>, ...)
1.75 rillig 3374: you will have to add the following line into
1.76 rillig 3375: <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 3376: <pre class="programlisting">
3377: X11_TYPE=xorg
1.1 grant 3378: </pre>
1.75 rillig 3379: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
3380: <h3 class="title">Note</h3>
3381: <p>The DragonFly operating system defaults to using
1.87 wiz 3382: this X.org X11 implementation from pkgsrc.</p>
1.75 rillig 3383: </div>
3384: </div>
3385: <div class="sect1" lang="en">
3386: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3387: <a name="fetch-behind-firewall"></a>8.8. How to fetch files from behind a firewall</h2></div></div></div>
1.75 rillig 3388: <p>If you are sitting behind a firewall which does not allow direct
3389: connections to Internet hosts (i.e. non-NAT), you may specify the
3390: relevant proxy hosts. This is done using an environment variable in the
3391: form of a URL, e.g. in Amdahl, the machine
3392: “<span class="quote">orpheus.amdahl.com</span>” is one of the firewalls, and it uses
3393: port 80 as the proxy port number. So the proxy environment variables
3394: are:</p>
3395: <pre class="programlisting">
3396: ftp_proxy=ftp://orpheus.amdahl.com:80/
3397: http_proxy=http://orpheus.amdahl.com:80/
1.1 grant 3398: </pre>
1.75 rillig 3399: </div>
3400: <div class="sect1" lang="en">
3401: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3402: <a name="passive-ftp"></a>8.9. How do I tell <span><strong class="command">make fetch</strong></span> to do passive FTP?</h2></div></div></div>
1.75 rillig 3403: <p>This depends on which utility is used to retrieve distfiles. From
1.76 rillig 3404: <code class="filename">bsd.pkg.mk</code>, <code class="varname">FETCH_CMD</code> is assigned
1.75 rillig 3405: the first available command from the following list:</p>
3406: <div class="itemizedlist"><ul type="disc">
1.76 rillig 3407: <li><p><code class="filename">${LOCALBASE}/bin/ftp</code></p></li>
3408: <li><p><code class="filename">/usr/bin/ftp</code></p></li>
1.75 rillig 3409: </ul></div>
3410: <p>On a default NetBSD installation, this will be
1.76 rillig 3411: <code class="filename">/usr/bin/ftp</code>, which automatically tries passive
1.75 rillig 3412: connections first, and falls back to active connections if the server
3413: refuses to do passive. For the other tools, add the following to your
1.76 rillig 3414: <code class="filename">/etc/mk.conf</code> file:
1.75 rillig 3415: <code class="varname">PASSIVE_FETCH=1</code>.</p>
3416: <p>Having that option present will prevent
1.76 rillig 3417: <code class="filename">/usr/bin/ftp</code> from falling back to active
1.75 rillig 3418: transfers.</p>
3419: </div>
3420: <div class="sect1" lang="en">
3421: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3422: <a name="fetching-all-distfiles"></a>8.10. How to fetch all distfiles at once</h2></div></div></div>
1.88 wiz 3423: <p>You would like to download all the distfiles in a single batch
3424: from work or university, where you can't run a <span><strong class="command">make
3425: fetch</strong></span>. There is an archive of distfiles on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/" target="_top">ftp.NetBSD.org</a>,
1.75 rillig 3426: but downloading the entire directory may not be appropriate.</p>
3427: <p>The answer here is to do a <span><strong class="command">make fetch-list</strong></span> in
1.76 rillig 3428: <code class="filename">/usr/pkgsrc</code> or one of its subdirectories, carry the
1.75 rillig 3429: resulting list to your machine at work/school and use it there. If you
3430: don't have a NetBSD-compatible <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ftp+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ftp</span>(1)</span></a> (like tnftp) at work, don't
3431: forget to set <code class="varname">FETCH_CMD</code> to something that fetches a
3432: URL:</p>
3433: <p>At home:</p>
3434: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
3435: <code class="prompt">%</code> <strong class="userinput"><code>make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh</code></strong>
3436: <code class="prompt">%</code> <strong class="userinput"><code>scp /tmp/fetch.sh work:/tmp</code></strong></pre>
3437: <p>At work:</p>
3438: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>sh /tmp/fetch.sh</code></strong></pre>
1.76 rillig 3439: <p>then tar up <code class="filename">/tmp/distfiles</code> and take it
1.75 rillig 3440: home.</p>
3441: <p>If you have a machine running NetBSD, and you want to get
1.88 wiz 3442: <span class="emphasis"><em>all</em></span> distfiles (even ones that aren't for your
3443: machine architecture), you can do so by using the above-mentioned
3444: <span><strong class="command">make fetch-list</strong></span> approach, or fetch the distfiles
3445: directly by running:</p>
1.75 rillig 3446: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make mirror-distfiles</code></strong></pre>
3447: <p>If you even decide to ignore
3448: <code class="varname">NO_{SRC,BIN}_ON_{FTP,CDROM}</code>, then you can get everything
3449: by running:</p>
3450: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch NO_SKIP=yes</code></strong></pre>
3451: </div>
3452: <div class="sect1" lang="en">
3453: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3454: <a name="tmac.andoc-missing"></a>8.11. What does “<span class="quote">Don't know how to make
1.75 rillig 3455: /usr/share/tmac/tmac.andoc</span>” mean?</h2></div></div></div>
1.76 rillig 3456: <p>When compiling the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a>
1.75 rillig 3457: package, you get the error from make that it doesn't know how to make
1.76 rillig 3458: <code class="filename">/usr/share/tmac/tmac.andoc</code>? This indicates that
1.75 rillig 3459: you don't have installed the “<span class="quote">text</span>” set (nroff, ...) from
3460: the NetBSD base distribution on your machine. It is recommended to do
3461: that to format man pages.</p>
1.76 rillig 3462: <p>In the case of the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_install/README.html" target="_top"><code class="filename">pkgtools/pkg_install</code></a> package, you
1.75 rillig 3463: can get away with setting <code class="varname">NOMAN=YES</code> either in the
1.76 rillig 3464: environment or in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 3465: </div>
3466: <div class="sect1" lang="en">
3467: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3468: <a name="bsd.own.mk-missing"></a>8.12. What does “<span class="quote">Could not find bsd.own.mk</span>” mean?</h2></div></div></div>
1.87 wiz 3469: <p>You didn't install the compiler set, <code class="filename">comp.tgz</code>,
1.75 rillig 3470: when you installed your NetBSD machine. Please get and install it, by
1.76 rillig 3471: extracting it in <code class="filename">/</code>:</p>
1.75 rillig 3472: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /</code></strong>
3473: <code class="prompt">#</code> <strong class="userinput"><code>tar --unlink -zxvpf .../comp.tgz</code></strong></pre>
1.76 rillig 3474: <p><code class="filename">comp.tgz</code> is part of every NetBSD release. Get
1.75 rillig 3475: the one that corresponds to your release (determine via <span><strong class="command">uname
3476: -r</strong></span>).</p>
3477: </div>
3478: <div class="sect1" lang="en">
3479: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3480: <a name="using-sudo-with-pkgsrc"></a>8.13. Using 'sudo' with pkgsrc</h2></div></div></div>
1.75 rillig 3481: <p>When installing packages as non-root user and using the just-in-time
3482: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?su+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">su</span>(1)</span></a> feature of pkgsrc, it can become annoying to type in the root
3483: password for each required package installed. To avoid this, the sudo
3484: package can be used, which does password caching over a limited time. To
3485: use it, install sudo (either as binary package or from
1.76 rillig 3486: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/sudo/README.html" target="_top"><code class="filename">security/sudo</code></a>) and then put the following
3487: into your <code class="filename">/etc/mk.conf</code>:</p>
1.75 rillig 3488: <pre class="programlisting">
3489: .if exists(${LOCALBASE}/bin/sudo)
3490: SU_CMD= ${LOCALBASE}/bin/sudo /bin/sh -c
3491: .endif
1.1 grant 3492: </pre>
1.75 rillig 3493: </div>
3494: <div class="sect1" lang="en">
3495: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3496: <a name="faq.conf"></a>8.14. How do I change the location of configuration files?</h2></div></div></div>
1.75 rillig 3497: <p>As the system administrator, you can choose where configuration files
3498: are installed. The default settings make all these files go into
1.76 rillig 3499: <code class="filename">${PREFIX}/etc</code> or some of its subdirectories; this may
1.75 rillig 3500: be suboptimal depending on your expectations (e.g., a read-only,
3501: NFS-exported <code class="varname">PREFIX</code> with a need of per-machine
3502: configuration of the provided packages).</p>
3503: <p>In order to change the defaults, you can modify the
3504: <code class="varname">PKG_SYSCONFBASE</code> variable (in
1.76 rillig 3505: <code class="filename">/etc/mk.conf</code>) to point to your preferred configuration
3506: directory; some common examples include <code class="filename">/etc</code> or
3507: <code class="filename">/etc/pkg</code>.</p>
1.75 rillig 3508: <p>Furthermore, you can change this value on a per-package basis by
3509: setting the <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> variable.
3510: <code class="varname">PKG_SYSCONFVAR</code>'s value usually matches the name of the
3511: package you would like to modify, that is, the contents of
3512: <code class="varname">PKGBASE</code>.</p>
3513: <p>Note that after changing these settings, you must rebuild and
3514: reinstall any affected packages.</p>
3515: </div>
3516: <div class="sect1" lang="en">
3517: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3518: <a name="audit-packages"></a>8.15. Automated security checks</h2></div></div></div>
1.75 rillig 3519: <p>Please be aware that there can often be bugs in third-party software,
3520: and some of these bugs can leave a machine vulnerable to exploitation by
3521: attackers. In an effort to lessen the exposure, the NetBSD packages team
3522: maintains a database of known-exploits to packages which have at one time
3523: been included in pkgsrc. The database can be downloaded automatically, and
3524: a security audit of all packages installed on a system can take place. To
1.76 rillig 3525: do this, install the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a> package. It has two
1.75 rillig 3526: components:</p>
3527: <div class="orderedlist"><ol type="1">
3528: <li>
3529: <p><span><strong class="command">download-vulnerability-list</strong></span>, an easy way to
3530: download a list of the security vulnerabilities information. This list
3531: is kept up to date by the NetBSD security officer and the NetBSD
3532: packages team, and is distributed from the NetBSD ftp server:</p>
3533: <p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/pkg-vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pub/NetBSD/packages/distfiles/pkg-vulnerabilities</a></p>
3534: </li>
3535: <li><p><span><strong class="command">audit-packages</strong></span>, an easy way to audit the
3536: current machine, checking each vulnerability which is known. If a
3537: vulnerable package is installed, it will be shown by output to stdout,
3538: including a description of the type of vulnerability, and a URL
3539: containing more information.</p></li>
3540: </ol></div>
1.76 rillig 3541: <p>Use of the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>
1.75 rillig 3542: package is strongly recommended! After
3543: “<span class="quote">audit-packages</span>” is installed, please read
3544: the package's message, which you can get by running <strong class="userinput"><code>pkg_info -D
3545: audit-packages</code></strong>.</p>
1.87 wiz 3546: <p>If this package is installed, pkgsrc builds will use it to
3547: perform a security check before building any package. See <a href="#variables-affecting-build" title="5.2. Variables affecting the build process">Section 5.2, “Variables affecting the build process”</a> for ways to control this
3548: check.</p>
1.75 rillig 3549: </div>
3550: <div class="sect1" lang="en">
3551: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3552: <a name="ufaq-cflags"></a>8.16. Why do some packages ignore my <code class="varname">CFLAGS</code>?</h2></div></div></div>
1.75 rillig 3553: <p>When you add your own preferences to the
3554: <code class="varname">CFLAGS</code> variable in your
1.76 rillig 3555: <code class="filename">mk.conf</code>, these flags are passed in
3556: environment variables to the <code class="filename">./configure</code>
1.75 rillig 3557: scripts and to <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>. Some package authors ignore the
3558: <code class="varname">CFLAGS</code> from the environment variable by
1.76 rillig 3559: overriding them in the <code class="filename">Makefile</code>s of their
1.75 rillig 3560: package.</p>
3561: <p>Currently there is no solution to this problem. If you
3562: really need the package to use your <code class="varname">CFLAGS</code>
3563: you should run <span><strong class="command">make patch</strong></span> in the package
1.76 rillig 3564: directory and then inspect any <code class="filename">Makefile</code> and
3565: <code class="filename">Makefile.in</code> for whether they define
1.75 rillig 3566: <code class="varname">CFLAGS</code> explicitly. Usually you can remove
3567: these lines. But be aware that some “<span class="quote">smart</span>”
3568: programmers write so bad code that it only works for the
3569: specific combination of <code class="varname">CFLAGS</code> they have
3570: chosen.</p>
3571: </div>
1.80 rillig 3572: <div class="sect1" lang="en">
3573: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3574: <a name="ufaq-fail"></a>8.17. A package does not build. What shall I do?</h2></div></div></div>
1.80 rillig 3575: <div class="procedure"><ol type="1">
3576: <li><p>Make sure that your copy of pkgsrc is consistent. A
3577: case that occurs often is that people only update pkgsrc in
3578: parts, because of performance reasons. Since pkgsrc is one large
3579: system, not a collection of many small systems, there are
3580: sometimes changes that only work when the whole pkgsrc tree is
3581: updated.</p></li>
3582: <li><p>Make sure that you don't have any CVS conflicts.
3583: Search for “<span class="quote"><<<<<<</span>” or
3584: “<span class="quote">>>>>>></span>” in all your pkgsrc
3585: files.</p></li>
3586: <li><p>Make sure that you don't have old copies of the packages
3587: extracted. Run <span><strong class="command">make clean clean-depends</strong></span> to
3588: verify this.</p></li>
3589: <li><p>If the problem still exists, write a mail to the
3590: <code class="literal">pkgsrc-users</code> mailing list.</p></li>
3591: </ol></div>
3592: </div>
1.88 wiz 3593: <div class="sect1" lang="en">
3594: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3595: <a name="faq.rcs-conflicts"></a>8.18. What does “<span class="quote">Makefile appears to contain unresolved cvs/rcs/??? merge conflicts</span>” mean?</h2></div></div></div>
1.89 rillig 3596: <p>You have modified a file from pkgsrc, and someone else has
3597: modified that same file afterwards in the CVS repository. Both changes
3598: are in the same region of the file, so when you updated pkgsrc, the
3599: <code class="literal">cvs</code> command marked the conflicting changes in the
3600: file. Because of these markers, the file is no longer a valid
3601: <code class="filename">Makefile</code>.</p>
3602: <p>Have a look at that file, and if you don't need your local changes
3603: anymore, you can remove that file and run <span><strong class="command">cvs -q update
3604: -dP</strong></span> in that directory to download the current version.</p>
3605: </div>
3606: <div class="sect1" lang="en">
3607: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3608: <a name="too-much-time"></a>8.19. I have a little time to kill. What shall I do?</h2></div></div></div>
1.88 wiz 3609: <p>This is not really an FAQ yet, but here's the answer
3610: anyway.</p>
3611: <div class="itemizedlist"><ul type="disc">
3612: <li><p>Run <span><strong class="command">pkg_chk -N</strong></span> (from the
3613: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_chk/README.html" target="_top"><code class="filename">pkgtools/pkg_chk</code></a> package). It
3614: will tell you about newer versions of installed packages that are
3615: available, but not yet updated in pkgsrc.</p></li>
3616: <li><p>Browse <code class="filename">pkgsrc/doc/TODO</code>
1.89 rillig 3617: — it contains a list of suggested new packages and a list of
1.88 wiz 3618: cleanups and enhancements for pkgsrc that would be nice to
3619: have.</p></li>
3620: <li><p>Review packages for which review was requested on
3621: the <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">pkgsrc-wip</a> review
3622: mailing list.</p></li>
3623: </ul></div>
3624: </div>
1.75 rillig 3625: </div>
3626: </div>
3627: <div class="part" lang="en">
3628: <div class="titlepage"><div><div><h1 class="title">
3629: <a name="developers-guide"></a>Part II. The pkgsrc developer's guide</h1></div></div></div>
1.77 rillig 3630: <div class="partintro" lang="en">
3631: <div></div>
3632: <p>This part of the book deals with creating and
3633: modifying packages. It starts with a “<span class="quote">HOWTO</span>”-like
3634: guide on creating a new package. The remaining chapters are more
3635: like a reference manual for pkgsrc.</p>
1.75 rillig 3636: <div class="toc">
3637: <p><b>Table of Contents</b></p>
3638: <dl>
1.90 ! rillig 3639: <dt><span class="chapter"><a href="#creating">9. Creating a new pkgsrc package from scratch</a></span></dt>
! 3640: <dt><span class="chapter"><a href="#components">10. Package components - files, directories and contents</a></span></dt>
1.75 rillig 3641: <dd><dl>
1.90 ! rillig 3642: <dt><span class="sect1"><a href="#components.Makefile">10.1. <code class="filename">Makefile</code></a></span></dt>
! 3643: <dt><span class="sect1"><a href="#components.distinfo">10.2. <code class="filename">distinfo</code></a></span></dt>
! 3644: <dt><span class="sect1"><a href="#components.patches">10.3. patches/*</a></span></dt>
! 3645: <dd><dl>
! 3646: <dt><span class="sect2"><a href="#components.patches.guidelines">10.3.1. Patching guidelines</a></span></dt>
! 3647: <dt><span class="sect2"><a href="#components.patches.feedback">10.3.2. Feedback to the author</a></span></dt>
! 3648: </dl></dd>
! 3649: <dt><span class="sect1"><a href="#other-mandatory-files">10.4. Other mandatory files</a></span></dt>
! 3650: <dt><span class="sect1"><a href="#components.optional">10.5. Optional files</a></span></dt>
! 3651: <dd><dl>
! 3652: <dt><span class="sect2"><a href="#components.optional.bin">10.5.1. Files affecting the binary package</a></span></dt>
! 3653: <dt><span class="sect2"><a href="#components.optional.build">10.5.2. Files affecting the build process</a></span></dt>
! 3654: <dt><span class="sect2"><a href="#components.optional.none">10.5.3. Files affecting nothing at all</a></span></dt>
! 3655: </dl></dd>
! 3656: <dt><span class="sect1"><a href="#work-dir">10.6. <code class="filename">work*</code></a></span></dt>
! 3657: <dt><span class="sect1"><a href="#files-dir">10.7. <code class="filename">files/*</code></a></span></dt>
! 3658: </dl></dd>
! 3659: <dt><span class="chapter"><a href="#makefile">11. Programming in <code class="filename">Makefile</code>s</a></span></dt>
! 3660: <dd><dl>
! 3661: <dt><span class="sect1"><a href="#makefile.variables">11.1. <code class="filename">Makefile</code> variables</a></span></dt>
! 3662: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">11.1.1. Naming conventions</a></span></dt></dl></dd>
! 3663: <dt><span class="sect1"><a href="#makefile.code">11.2. Code snippets</a></span></dt>
! 3664: <dd><dl>
! 3665: <dt><span class="sect2"><a href="#adding-to-list">11.2.1. Adding things to a list</a></span></dt>
! 3666: <dt><span class="sect2"><a href="#converting-internal-to-external">11.2.2. Converting an internal list into an external list</a></span></dt>
! 3667: <dt><span class="sect2"><a href="#passing-variable-to-shell">11.2.3. Passing variables to a shell command</a></span></dt>
! 3668: <dt><span class="sect2"><a href="#quoting-guideline">11.2.4. Quoting guideline</a></span></dt>
! 3669: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">11.2.5. Workaround for a bug in BSD Make</a></span></dt>
! 3670: </dl></dd>
! 3671: </dl></dd>
! 3672: <dt><span class="chapter"><a href="#plist">12. PLIST issues</a></span></dt>
! 3673: <dd><dl>
! 3674: <dt><span class="sect1"><a href="#rcs-id">12.1. RCS ID</a></span></dt>
! 3675: <dt><span class="sect1"><a href="#automatic-plist-generation">12.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
! 3676: <dt><span class="sect1"><a href="#print-PLIST">12.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
! 3677: <dt><span class="sect1"><a href="#plist.misc">12.4. Variable substitution in PLIST</a></span></dt>
! 3678: <dt><span class="sect1"><a href="#manpage-compression">12.5. Man page compression</a></span></dt>
! 3679: <dt><span class="sect1"><a href="#using-PLIST_SRC">12.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
! 3680: <dt><span class="sect1"><a href="#platform-specific-plist">12.7. Platform-specific and differing PLISTs</a></span></dt>
! 3681: <dt><span class="sect1"><a href="#faq.common-dirs">12.8. Sharing directories between packages</a></span></dt>
! 3682: </dl></dd>
! 3683: <dt><span class="chapter"><a href="#buildlink">13. Buildlink methodology</a></span></dt>
! 3684: <dd><dl>
! 3685: <dt><span class="sect1"><a href="#converting-to-buildlink3">13.1. Converting packages to use buildlink3</a></span></dt>
! 3686: <dt><span class="sect1"><a href="#creating-buildlink3.mk">13.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
! 3687: <dd><dl>
! 3688: <dt><span class="sect2"><a href="#anatomy-of-bl3">13.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
! 3689: <dt><span class="sect2"><a href="#updating-buildlink-depends">13.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>
! 3690: </dl></dd>
! 3691: <dt><span class="sect1"><a href="#writing-builtin.mk">13.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
! 3692: <dd><dl>
! 3693: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">13.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
! 3694: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">13.3.2. Global preferences for native or pkgsrc software</a></span></dt>
! 3695: </dl></dd>
! 3696: </dl></dd>
! 3697: <dt><span class="chapter"><a href="#pkginstall">14. The pkginstall framework</a></span></dt>
! 3698: <dd><dl>
! 3699: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">14.1. Files and directories outside the installation prefix</a></span></dt>
! 3700: <dd><dl>
! 3701: <dt><span class="sect2"><a href="#dirs-outside-prefix">14.1.1. Directory manipulation</a></span></dt>
! 3702: <dt><span class="sect2"><a href="#files-outside-prefix">14.1.2. File manipulation</a></span></dt>
! 3703: </dl></dd>
! 3704: <dt><span class="sect1"><a href="#conf-files">14.2. Configuration files</a></span></dt>
! 3705: <dd><dl>
! 3706: <dt><span class="sect2"><a href="#conf-files-sysconfdir">14.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
! 3707: <dt><span class="sect2"><a href="#conf-files-configure">14.2.2. Telling the software where configuration files are</a></span></dt>
! 3708: <dt><span class="sect2"><a href="#conf-files-patching">14.2.3. Patching installations</a></span></dt>
! 3709: <dt><span class="sect2"><a href="#conf-files-disable">14.2.4. Disabling handling of configuration files</a></span></dt>
! 3710: </dl></dd>
! 3711: <dt><span class="sect1"><a href="#rcd-scripts">14.3. System startup scripts</a></span></dt>
! 3712: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">14.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
! 3713: <dt><span class="sect1"><a href="#users-and-groups">14.4. System users and groups</a></span></dt>
! 3714: <dt><span class="sect1"><a href="#shells">14.5. System shells</a></span></dt>
! 3715: <dd><dl><dt><span class="sect2"><a href="#shells-disable">14.5.1. Disabling shell registration</a></span></dt></dl></dd>
! 3716: <dt><span class="sect1"><a href="#fonts">14.6. Fonts</a></span></dt>
! 3717: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">14.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
! 3718: </dl></dd>
! 3719: <dt><span class="chapter"><a href="#options">15. Options handling</a></span></dt>
! 3720: <dd><dl>
! 3721: <dt><span class="sect1"><a href="#global-default-options">15.1. Global default options</a></span></dt>
! 3722: <dt><span class="sect1"><a href="#converting-to-options">15.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
! 3723: <dt><span class="sect1"><a href="#option-names">15.3. Option Names</a></span></dt>
! 3724: </dl></dd>
! 3725: <dt><span class="chapter"><a href="#build">16. The build process</a></span></dt>
! 3726: <dd><dl>
! 3727: <dt><span class="sect1"><a href="#build.intro">16.1. Introduction</a></span></dt>
! 3728: <dt><span class="sect1"><a href="#build.prefix">16.2. Program location</a></span></dt>
! 3729: <dt><span class="sect1"><a href="#build.builddirs">16.3. Directories used during the build process</a></span></dt>
! 3730: <dt><span class="sect1"><a href="#build.running">16.4. Running a phase</a></span></dt>
! 3731: <dt><span class="sect1"><a href="#build.fetch">16.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
! 3732: <dd><dl>
! 3733: <dt><span class="sect2"><a href="#build.fetch.what">16.5.1. What to fetch and where to get it from</a></span></dt>
! 3734: <dt><span class="sect2"><a href="#build.fetch.how">16.5.2. How are the files fetched?</a></span></dt>
! 3735: </dl></dd>
! 3736: <dt><span class="sect1"><a href="#build.checksum">16.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
! 3737: <dt><span class="sect1"><a href="#build.extract">16.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
! 3738: <dt><span class="sect1"><a href="#build.patch">16.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
! 3739: <dt><span class="sect1"><a href="#build.tools">16.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
! 3740: <dt><span class="sect1"><a href="#build.wrapper">16.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
! 3741: <dt><span class="sect1"><a href="#build.configure">16.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
! 3742: <dt><span class="sect1"><a href="#build.build">16.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
! 3743: <dt><span class="sect1"><a href="#build.test">16.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
! 3744: <dt><span class="sect1"><a href="#build.install">16.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
! 3745: <dt><span class="sect1"><a href="#build.package">16.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
! 3746: <dt><span class="sect1"><a href="#build.clean">16.16. Cleaning up</a></span></dt>
! 3747: <dt><span class="sect1"><a href="#build.helpful-targets">16.17. Other helpful targets</a></span></dt>
! 3748: </dl></dd>
! 3749: <dt><span class="chapter"><a href="#tools">17. Tools needed for building or running</a></span></dt>
! 3750: <dd><dl>
! 3751: <dt><span class="sect1"><a href="#pkgsrc-tools">17.1. Tools for pkgsrc builds</a></span></dt>
! 3752: <dt><span class="sect1"><a href="#package-tools">17.2. Tools needed by packages</a></span></dt>
! 3753: <dt><span class="sect1"><a href="#platform-tools">17.3. Tools provided by platforms</a></span></dt>
! 3754: </dl></dd>
! 3755: <dt><span class="chapter"><a href="#fixes">18. Making your package work</a></span></dt>
! 3756: <dd><dl>
! 3757: <dt><span class="sect1"><a href="#general-operation">18.1. General operation</a></span></dt>
! 3758: <dd><dl>
! 3759: <dt><span class="sect2"><a href="#portability-of-packages">18.1.1. Portability of packages</a></span></dt>
! 3760: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">18.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
! 3761: <dt><span class="sect2"><a href="#user-interaction">18.1.3. User interaction</a></span></dt>
! 3762: <dt><span class="sect2"><a href="#handling-licenses">18.1.4. Handling licenses</a></span></dt>
! 3763: <dt><span class="sect2"><a href="#restricted-packages">18.1.5. Restricted packages</a></span></dt>
! 3764: <dt><span class="sect2"><a href="#dependencies">18.1.6. Handling dependencies</a></span></dt>
! 3765: <dt><span class="sect2"><a href="#conflicts">18.1.7. Handling conflicts with other packages</a></span></dt>
! 3766: <dt><span class="sect2"><a href="#not-building-packages">18.1.8. Packages that cannot or should not be built</a></span></dt>
! 3767: <dt><span class="sect2"><a href="#undeletable-packages">18.1.9. Packages which should not be deleted, once installed</a></span></dt>
! 3768: <dt><span class="sect2"><a href="#security-handling">18.1.10. Handling packages with security problems</a></span></dt>
! 3769: <dt><span class="sect2"><a href="#bumping-pkgrevision">18.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
! 3770: <dt><span class="sect2"><a href="#fixes.subst">18.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
! 3771: </dl></dd>
! 3772: <dt><span class="sect1"><a href="#fixes.fetch">18.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
! 3773: <dd><dl>
! 3774: <dt><span class="sect2"><a href="#no-plain-download">18.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
! 3775: <dt><span class="sect2"><a href="#modified-distfiles-same-name">18.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
! 3776: </dl></dd>
! 3777: <dt><span class="sect1"><a href="#fixes.configure">18.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
! 3778: <dd><dl>
! 3779: <dt><span class="sect2"><a href="#fixes.libtool">18.3.1. Shared libraries - libtool</a></span></dt>
! 3780: <dt><span class="sect2"><a href="#using-libtool">18.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
! 3781: <dt><span class="sect2"><a href="#autoconf-automake">18.3.3. GNU Autoconf/Automake</a></span></dt>
! 3782: </dl></dd>
! 3783: <dt><span class="sect1"><a href="#programming-languages">18.4. Programming languages</a></span></dt>
! 3784: <dd><dl>
! 3785: <dt><span class="sect2"><a href="#basic-programming-languages">18.4.1. C, C++, and Fortran</a></span></dt>
! 3786: <dt><span class="sect2"><a href="#java-programming-language">18.4.2. Java</a></span></dt>
! 3787: <dt><span class="sect2"><a href="#perl-scripts">18.4.3. Packages containing perl scripts</a></span></dt>
! 3788: <dt><span class="sect2"><a href="#other-programming-languages">18.4.4. Other programming languages</a></span></dt>
! 3789: </dl></dd>
! 3790: <dt><span class="sect1"><a href="#fixes.build">18.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
! 3791: <dd><dl>
! 3792: <dt><span class="sect2"><a href="#fixes.build.cpp">18.5.1. Compiling C and C++ code conditionally</a></span></dt>
! 3793: <dt><span class="sect2"><a href="#compiler-bugs">18.5.2. How to handle compiler bugs</a></span></dt>
! 3794: <dt><span class="sect2"><a href="#undefined-reference">18.5.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
! 3795: <dt><span class="sect2"><a href="#out-of-memory">18.5.4. Running out of memory</a></span></dt>
! 3796: </dl></dd>
! 3797: <dt><span class="sect1"><a href="#fixes.install">18.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
! 3798: <dd><dl>
! 3799: <dt><span class="sect2"><a href="#install-scripts">18.6.1. Creating needed directories</a></span></dt>
! 3800: <dt><span class="sect2"><a href="#where-to-install-documentation">18.6.2. Where to install documentation</a></span></dt>
! 3801: <dt><span class="sect2"><a href="#installing-score-files">18.6.3. Installing score files</a></span></dt>
! 3802: <dt><span class="sect2"><a href="#hardcoded-paths">18.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
! 3803: <dt><span class="sect2"><a href="#perl-modules">18.6.5. Packages installing perl modules</a></span></dt>
! 3804: <dt><span class="sect2"><a href="#faq.info-files">18.6.6. Packages installing info files</a></span></dt>
! 3805: <dt><span class="sect2"><a href="#manpages">18.6.7. Packages installing man pages</a></span></dt>
! 3806: <dt><span class="sect2"><a href="#gconf2-data-files">18.6.8. Packages installing GConf2 data files</a></span></dt>
! 3807: <dt><span class="sect2"><a href="#scrollkeeper-data-files">18.6.9. Packages installing scrollkeeper data files</a></span></dt>
! 3808: <dt><span class="sect2"><a href="#x11-fonts">18.6.10. Packages installing X11 fonts</a></span></dt>
! 3809: <dt><span class="sect2"><a href="#gtk2-modules">18.6.11. Packages installing GTK2 modules</a></span></dt>
! 3810: <dt><span class="sect2"><a href="#sgml-xml-data">18.6.12. Packages installing SGML or XML data</a></span></dt>
! 3811: <dt><span class="sect2"><a href="#mime-database">18.6.13. Packages installing extensions to the MIME database</a></span></dt>
! 3812: <dt><span class="sect2"><a href="#intltool">18.6.14. Packages using intltool</a></span></dt>
! 3813: <dt><span class="sect2"><a href="#startup-scripts">18.6.15. Packages installing startup scripts</a></span></dt>
! 3814: <dt><span class="sect2"><a href="#tex-packages">18.6.16. Packages installing TeX modules</a></span></dt>
! 3815: <dt><span class="sect2"><a href="#emulation-packages">18.6.17. Packages supporting running binaries in
1.87 wiz 3816: emulation</a></span></dt>
1.90 ! rillig 3817: <dt><span class="sect2"><a href="#hicolor-theme">18.6.18. Packages installing hicolor theme icons</a></span></dt>
! 3818: <dt><span class="sect2"><a href="#desktop-files">18.6.19. Packages installing desktop files</a></span></dt>
1.77 rillig 3819: </dl></dd>
1.90 ! rillig 3820: <dt><span class="sect1"><a href="#punting">18.7. Marking packages as having problems</a></span></dt>
1.77 rillig 3821: </dl></dd>
1.90 ! rillig 3822: <dt><span class="chapter"><a href="#debug">19. Debugging</a></span></dt>
! 3823: <dt><span class="chapter"><a href="#submit">20. Submitting and Committing</a></span></dt>
1.77 rillig 3824: <dd><dl>
1.90 ! rillig 3825: <dt><span class="sect1"><a href="#submitting-binary-packages">20.1. Submitting binary packages</a></span></dt>
! 3826: <dt><span class="sect1"><a href="#submitting-your-package">20.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
! 3827: <dt><span class="sect1"><a href="#general-notes-for-changes">20.3. General notes when adding, updating, or removing packages</a></span></dt>
! 3828: <dt><span class="sect1"><a href="#committing-importing">20.4. Committing: Importing a package into CVS</a></span></dt>
! 3829: <dt><span class="sect1"><a href="#updating-package">20.5. Updating a package to a newer version</a></span></dt>
! 3830: <dt><span class="sect1"><a href="#moving-package">20.6. Moving a package in pkgsrc</a></span></dt>
! 3831: </dl></dd>
! 3832: <dt><span class="chapter"><a href="#devfaq">21. Frequently Asked Questions</a></span></dt>
! 3833: <dt><span class="chapter"><a href="#gnome">22. GNOME packaging and porting</a></span></dt>
! 3834: <dd><dl>
! 3835: <dt><span class="sect1"><a href="#meta-packages">22.1. Meta packages</a></span></dt>
! 3836: <dt><span class="sect1"><a href="#new-package">22.2. Packaging a GNOME application</a></span></dt>
! 3837: <dt><span class="sect1"><a href="#full-update">22.3. Updating GNOME to a newer version</a></span></dt>
! 3838: <dt><span class="sect1"><a href="#patching">22.4. Patching guidelines</a></span></dt>
1.85 jmmv 3839: </dl></dd>
1.75 rillig 3840: </dl>
3841: </div>
1.77 rillig 3842: </div>
3843: <div class="chapter" lang="en">
3844: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 3845: <a name="creating"></a>Chapter 9. Creating a new pkgsrc package from scratch</h2></div></div></div>
1.77 rillig 3846: <p>When you find a package that is not yet in pkgsrc, you
3847: most likely have a URL from where you can download the source
3848: code. Starting with this URL, creating a package involves only a
3849: few steps.</p>
3850: <div class="procedure"><ol type="1">
3851: <li><p>First, install the packages <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a> and <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>.</p></li>
3852: <li><p>Then, choose one of the top-level directories as the
3853: category in which you want to place your package. You can also
3854: create a directory of your own (maybe called
3855: <code class="filename">local</code>). In that category directory, create
3856: another directory for your package and change into
3857: it.</p></li>
3858: <li><p>Run the program <span><strong class="command">url2pkg</strong></span>, which
3859: will ask you for a URL. Enter the URL of the distribution file
3860: (in most cases a <code class="filename">.tar.gz</code> file) and watch
3861: how the basic ingredients of your package are created
3862: automatically. The distribution file is extracted automatically
3863: to fill in some details in the <code class="filename">Makefile</code>
3864: that would otherwise have to be done manually.</p></li>
3865: <li>
3866: <p>Examine the extracted files to determine the
3867: dependencies of your package. Ideally, this is mentioned in some
3868: <code class="filename">README</code> file, but things may differ. For
3869: each of these dependencies, look where it exists in pkgsrc, and
3870: if there is a file called <code class="filename">buildlink3.mk</code> in
3871: that directory, add a line to your package
3872: <code class="filename">Makefile</code> which includes that file just
3873: before the last line. If the <code class="filename">buildlink3.mk</code>
3874: file does not exist, add a <code class="varname">DEPENDS</code> line to
3875: the Makefile, which specifies the version of the dependency and
3876: where it can be found in pkgsrc. This line should be placed in
3877: the third paragraph. If the dependency is only needed for
3878: building the package, but not when using it, use
3879: <code class="varname">BUILD_DEPENDS</code> instead of
3880: <code class="varname">DEPENDS</code>. Your package may then look like
3881: this:</p>
3882: <pre class="programlisting">
3883: [...]
3884:
3885: BUILD_DEPENDS+= lua>=5.0:../../lang/lua
3886: DEPENDS+= screen-[0-9]*:../../misc/screen
3887: DEPENDS+= screen>=4.0:../../misc/screen
3888:
3889: [...]
3890:
3891: .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
3892: .include "../../devel/glib2/buildlink3.mk"
3893: .include "../../mk/bsd.pkg.mk"
3894: </pre>
3895: </li>
3896: <li><p>Run <span><strong class="command">pkglint</strong></span> to see what things
3897: still need to be done to make your package a “<span class="quote">good</span>”
3898: one. If you don't know what pkglint's warnings want to tell you,
3899: try <span><strong class="command">pkglint --explain</strong></span> or <span><strong class="command">pkglint
3900: -e</strong></span>, which outputs additional
3901: explanations.</p></li>
3902: <li><p>Now, run <span><strong class="command">bmake</strong></span> to build the
3903: package. For the various things that can go wrong in this phase,
1.90 ! rillig 3904: consult <a href="#fixes" title="Chapter 18. Making your package work">Chapter 18, <i>Making your package work</i></a>.</p></li>
1.77 rillig 3905: <li><p>When the package builds fine, the next step is to
3906: install the package. Run <span><strong class="command">bmake install</strong></span> and
3907: hope that everything works.</p></li>
3908: <li><p>Up to now, the file <code class="filename">PLIST</code>,
3909: which contains a list of the files that are installed by the
3910: package, is nearly empty. Run <span><strong class="command">bmake print-PLIST
3911: >PLIST</strong></span> to generate a probably correct list. Check
3912: the file using your preferred text editor to see if the list of
3913: files looks plausible.</p></li>
3914: <li><p>Run <span><strong class="command">pkglint</strong></span> again to see if the
3915: generated <code class="filename">PLIST</code> contains garbage or
3916: not.</p></li>
3917: <li><p>When you ran <span><strong class="command">bmake install</strong></span>, the
3918: package has been registered in the database of installed files,
3919: but with an empty list of files. To fix this, run <span><strong class="command">bmake
3920: deinstall</strong></span> and <span><strong class="command">bmake install</strong></span> again.
3921: Now the package is registered with the list of files from
3922: <code class="filename">PLIST</code>.</p></li>
3923: <li><p>Run <span><strong class="command">bmake package</strong></span> to create a
3924: binary package from the set of installed files.</p></li>
3925: </ol></div>
3926: </div>
1.75 rillig 3927: <div class="chapter" lang="en">
3928: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 3929: <a name="components"></a>Chapter 10. Package components - files, directories and contents</h2></div></div></div>
1.75 rillig 3930: <div class="toc">
3931: <p><b>Table of Contents</b></p>
3932: <dl>
1.90 ! rillig 3933: <dt><span class="sect1"><a href="#components.Makefile">10.1. <code class="filename">Makefile</code></a></span></dt>
! 3934: <dt><span class="sect1"><a href="#components.distinfo">10.2. <code class="filename">distinfo</code></a></span></dt>
! 3935: <dt><span class="sect1"><a href="#components.patches">10.3. patches/*</a></span></dt>
! 3936: <dd><dl>
! 3937: <dt><span class="sect2"><a href="#components.patches.guidelines">10.3.1. Patching guidelines</a></span></dt>
! 3938: <dt><span class="sect2"><a href="#components.patches.feedback">10.3.2. Feedback to the author</a></span></dt>
! 3939: </dl></dd>
! 3940: <dt><span class="sect1"><a href="#other-mandatory-files">10.4. Other mandatory files</a></span></dt>
! 3941: <dt><span class="sect1"><a href="#components.optional">10.5. Optional files</a></span></dt>
! 3942: <dd><dl>
! 3943: <dt><span class="sect2"><a href="#components.optional.bin">10.5.1. Files affecting the binary package</a></span></dt>
! 3944: <dt><span class="sect2"><a href="#components.optional.build">10.5.2. Files affecting the build process</a></span></dt>
! 3945: <dt><span class="sect2"><a href="#components.optional.none">10.5.3. Files affecting nothing at all</a></span></dt>
1.78 rillig 3946: </dl></dd>
1.90 ! rillig 3947: <dt><span class="sect1"><a href="#work-dir">10.6. <code class="filename">work*</code></a></span></dt>
! 3948: <dt><span class="sect1"><a href="#files-dir">10.7. <code class="filename">files/*</code></a></span></dt>
1.75 rillig 3949: </dl>
3950: </div>
1.87 wiz 3951: <p>Whenever you're preparing a package, there are a number of
3952: files involved which are described in the following
3953: sections.</p>
1.75 rillig 3954: <div class="sect1" lang="en">
3955: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 3956: <a name="components.Makefile"></a>10.1. <code class="filename">Makefile</code></h2></div></div></div>
1.75 rillig 3957: <p>Building, installation and creation of a binary package are all
1.87 wiz 3958: controlled by the package's <code class="filename">Makefile</code>.
3959: The <code class="filename">Makefile</code> describes various things about
3960: a package, for example from where to get it, how to configure,
3961: build, and install it.</p>
1.76 rillig 3962: <p>A package <code class="filename">Makefile</code> contains several
1.87 wiz 3963: sections that describe the package.</p>
1.75 rillig 3964: <p>In the first section there are the following variables, which
1.87 wiz 3965: should appear exactly in the order given here. The order and
3966: grouping of the variables is mostly historical and has no further
3967: meaning.</p>
1.75 rillig 3968: <div class="itemizedlist"><ul type="disc">
3969: <li><p><code class="varname">DISTNAME</code> is the basename of the
1.87 wiz 3970: distribution file to be downloaded from the package's
3971: website.</p></li>
1.75 rillig 3972: <li><p><code class="varname">PKGNAME</code> is the name of the
1.87 wiz 3973: package, as used by pkgsrc. You only need to provide it if
3974: <code class="varname">DISTNAME</code> (which is the default) is not a good
3975: name for the package in pkgsrc. Usually it is the pkgsrc
3976: directory name together with the version number. It must match the
3977: regular expression
3978: <code class="varname">^[A-Za-z0-9][A-Za-z0-9-_.+]*$</code>, that is, it
3979: starts with a letter or digit, and contains only letters, digits,
3980: dashes, underscores, dots and plus signs.</p></li>
3981: <li><p><code class="varname">SVR4_PKGNAME</code> is the name of
3982: the package file to create if the <code class="varname">PKGNAME</code>
3983: isn't unique on a SVR4 system. The default is
3984: <code class="varname">PKGNAME</code>, which may be shortened when you use
3985: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/gensolpkg/README.html" target="_top"><code class="filename">pkgtools/gensolpkg</code></a>. Only add
3986: <code class="varname">SVR4_PKGNAME</code> if <code class="varname">PKGNAME</code>
3987: does not produce an unique package name on a SVR4 system.
3988: The length of <code class="varname">SVR4_PKGNAME</code> is limited to 5
3989: characters.</p></li>
1.75 rillig 3990: <li>
3991: <p><code class="varname">CATEGORIES</code> is a list of categories
1.87 wiz 3992: which the package fits in. You can choose any of the top-level
3993: directories of pkgsrc for it.</p>
1.75 rillig 3994: <p>Currently the following values are available for
1.87 wiz 3995: <code class="varname">CATEGORIES</code>. If more than
3996: one is used, they need to be separated by spaces:</p>
1.75 rillig 3997: <pre class="programlisting">
1.87 wiz 3998: archivers cross geography meta-pkgs security
3999: audio databases graphics misc shells
4000: benchmarks devel ham multimedia sysutils
4001: biology editors inputmethod net textproc
4002: cad emulators lang news time
4003: chat finance mail parallel wm
4004: comms fonts math pkgtools www
4005: converters games mbone print x11
4006: </pre>
1.75 rillig 4007: </li>
1.81 rillig 4008: <li><p><code class="varname">MASTER_SITES</code>,
1.87 wiz 4009: <code class="varname">DYNAMIC_MASTER_SITES</code>,
4010: <code class="varname">DIST_SUBDIR</code>, <code class="varname">EXTRACT_SUFX</code>
4011: and <code class="varname">DISTFILES</code> are discussed in detail in
1.90 ! rillig 4012: <a href="#build.fetch" title="16.5. The fetch phase">Section 16.5, “The <span class="emphasis"><em>fetch</em></span> phase”</a>.</p></li>
1.75 rillig 4013: </ul></div>
4014: <p>The second section contains information about separately
1.87 wiz 4015: downloaded patches, if any.
4016: </p>
1.75 rillig 4017: <div class="itemizedlist"><ul type="disc">
4018: <li><p><code class="varname">PATCHFILES:</code>
1.87 wiz 4019: Name(s) of additional files that contain distribution patches.
4020: There is no default. pkgsrc will look for them at
4021: <code class="varname">PATCH_SITES</code>.
4022: They will automatically be uncompressed before patching if
4023: the names end with <code class="filename">.gz</code> or
4024: <code class="filename">.Z</code>.</p></li>
1.75 rillig 4025: <li><p><code class="varname">PATCH_SITES</code>:
1.87 wiz 4026: Primary location(s) for distribution patch files (see
4027: <code class="varname">PATCHFILES</code> below) if not found locally.</p></li>
1.75 rillig 4028: </ul></div>
4029: <p>The third section contains the following variables.
1.87 wiz 4030: </p>
1.75 rillig 4031: <div class="itemizedlist"><ul type="disc">
4032: <li><p><code class="varname">MAINTAINER</code> is the email address
1.87 wiz 4033: of the person who feels responsible for this package, and who is
4034: most likely to look at problems or questions regarding this
4035: package which have been reported with <a href="http://netbsd.gw.com/cgi-bin/man-cgi?send-pr+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">send-pr</span>(1)</span></a>. Other
4036: developers should contact the <code class="varname">MAINTAINER</code> before
4037: making major changes to the package. When packaging a new program,
4038: set <code class="varname">MAINTAINER</code> to yourself. If you really can't
4039: maintain the package for future updates, set it to
4040: <code class="email"><<a href="mailto:pkgsrc-users@NetBSD.org">pkgsrc-users@NetBSD.org</a>></code>.</p></li>
1.75 rillig 4041: <li><p><code class="varname">HOMEPAGE</code> is a URL where users can
1.87 wiz 4042: find more information about the package.</p></li>
1.75 rillig 4043: <li><p><code class="varname">COMMENT</code> is a one-line
1.87 wiz 4044: description of the package (should not include the package
4045: name).</p></li>
1.75 rillig 4046: </ul></div>
4047: <p>Other variables that affect the build:
1.87 wiz 4048: </p>
1.75 rillig 4049: <div class="itemizedlist"><ul type="disc"><li>
4050: <p><code class="varname">WRKSRC</code>: The directory where the
1.87 wiz 4051: interesting distribution files of the package are found. The
4052: default is <code class="filename">${WRKDIR}/${DISTNAME}</code>, which
4053: works for most packages.</p>
1.75 rillig 4054: <p>If a package doesn't create a subdirectory for itself
1.87 wiz 4055: (most GNU software does, for instance), but extracts itself in
4056: the current directory, you should set
4057: <code class="varname">WRKSRC=${WRKDIR}</code>.</p>
4058: <p>If a package doesn't create a subdirectory with the
4059: name of <code class="varname">DISTNAME</code> but some different name,
4060: set <code class="varname">WRKSRC</code> to point to the proper name in
4061: <code class="filename">${WRKDIR}</code>, for example
4062: <code class="varname">WRKSRC=${WRKDIR}/${DISTNAME}/unix</code>. See
4063: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/lang/tcl/README.html" target="_top"><code class="filename">lang/tcl</code></a> and <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/tk/README.html" target="_top"><code class="filename">x11/tk</code></a> for other examples.</p>
1.75 rillig 4064: <p>The name of the working directory created by pkgsrc is
1.87 wiz 4065: taken from the <code class="varname">WRKDIR_BASENAME</code>
4066: variable. By default, its value is
4067: <code class="filename">work</code>. If you want to use the same
4068: pkgsrc tree for building different kinds of binary packages,
4069: you can change the variable according to your needs. Two
4070: other variables handle common cases of setting
4071: <code class="varname">WRKDIR_BASENAME</code> individually. If
4072: <code class="varname">OBJHOSTNAME</code> is defined in
4073: <code class="filename">/etc/mk.conf</code>, the first component of
4074: the host's name is attached to the directory name. If
4075: <code class="varname">OBJMACHINE</code> is defined, the platform name
4076: is attached, which might look like
4077: <code class="filename">work.i386</code> or
4078: <code class="filename">work.sparc</code>.</p>
1.75 rillig 4079: </li></ul></div>
4080: <p>Please pay attention to the following gotchas:</p>
4081: <div class="itemizedlist"><ul type="disc">
1.87 wiz 4082: <li><p>Add <code class="varname">MANCOMPRESSED</code> if man pages are
1.88 wiz 4083: installed in compressed form by the package. For packages using
4084: BSD-style makefiles which honor MANZ, there is
4085: <code class="varname">MANCOMPRESSED_IF_MANZ</code>.</p></li>
1.76 rillig 4086: <li><p>Replace <code class="filename">/usr/local</code> with
1.88 wiz 4087: “<span class="quote">${PREFIX}</span>” in all files (see patches,
4088: below).</p></li>
1.90 ! rillig 4089: <li><p>If the package installs any info files, see <a href="#faq.info-files" title="18.6.6. Packages installing info files">Section 18.6.6, “Packages installing info files”</a>.</p></li>
1.75 rillig 4090: </ul></div>
4091: </div>
4092: <div class="sect1" lang="en">
4093: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4094: <a name="components.distinfo"></a>10.2. <code class="filename">distinfo</code></h2></div></div></div>
1.76 rillig 4095: <p>The <code class="filename">distinfo</code> file contains the message
1.87 wiz 4096: digest, or checksum, of each distfile needed for the package. This
4097: ensures that the distfiles retrieved from the Internet have not been
4098: corrupted during transfer or altered by a malign force to introduce
4099: a security hole. Due to recent rumor about weaknesses of digest
4100: algorithms, all distfiles are protected using both SHA1 and RMD160
4101: message digests, as well as the file size.</p>
1.76 rillig 4102: <p>The <code class="filename">distinfo</code> file also contains the
1.87 wiz 4103: checksums for all the patches found in the
1.90 ! rillig 4104: <code class="filename">patches</code> directory (see <a href="#components.patches" title="10.3. patches/*">Section 10.3, “patches/*”</a>).</p>
1.76 rillig 4105: <p>To regenerate the <code class="filename">distinfo</code> file, use the
1.87 wiz 4106: <span><strong class="command">make makedistinfo</strong></span> or <span><strong class="command">make mdi</strong></span>
4107: command.</p>
1.75 rillig 4108: <p>Some packages have different sets of distfiles depending on
1.87 wiz 4109: the platform, for example <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/navigator/README.html" target="_top"><code class="filename">www/navigator</code></a>). These are kept in the same
4110: <code class="filename">distinfo</code> file and care should be taken when
4111: upgrading such a package to ensure distfile information is not
4112: lost.</p>
1.75 rillig 4113: </div>
4114: <div class="sect1" lang="en">
4115: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4116: <a name="components.patches"></a>10.3. patches/*</h2></div></div></div>
1.75 rillig 4117: <p>This directory contains files that are used by the
1.87 wiz 4118: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?patch+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">patch</span>(1)</span></a> command to
4119: modify the sources as distributed in the distribution file into a form
4120: that will compile and run perfectly on NetBSD. The files are applied
4121: successively in alphabetic order (as returned by a shell
4122: “<span class="quote">patches/patch-*</span>” glob expansion), so
4123: <code class="filename">patch-aa</code> is applied before
4124: <code class="filename">patch-ab</code>, etc.</p>
1.76 rillig 4125: <p>The <code class="filename">patch-*</code> files should be in
1.87 wiz 4126: <span><strong class="command">diff -bu</strong></span> format, and apply without a fuzz to avoid
4127: problems. (To force patches to apply
4128: with fuzz you can set <code class="varname">PATCH_FUZZ_FACTOR=-F2</code>).
4129: Furthermore, do not put changes for more than one file into a single
4130: patch file, as this will make future modifications more difficult.</p>
1.75 rillig 4131: <p>Similar, a file should be patched at most once, not several times by
1.87 wiz 4132: several different patches. If a file needs several patches, they should
4133: be combined into one file.</p>
1.75 rillig 4134: <p>One important thing to mention is to pay attention that no RCS IDs
1.87 wiz 4135: get stored in the patch files, as these will cause problems when
4136: later checked into the NetBSD CVS tree. Use the
4137: <span><strong class="command">pkgdiff</strong></span> from the
4138: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a> package to avoid
4139: these problems.</p>
4140: <p>For even more automation, we recommend using
4141: <span><strong class="command">mkpatches</strong></span> from the same package to make a
4142: whole set of patches. You just have to backup files before you
4143: edit them to <code class="filename">filename.orig</code>, e.g. with
4144: <span><strong class="command">cp -p filename filename.orig</strong></span> or, easier, by
4145: using <span><strong class="command">pkgvi</strong></span> again from the same package. If
4146: you upgrade a package this way, you can easily compare the new
4147: set of patches with the previously existing one with
4148: <span><strong class="command">patchdiff</strong></span>. Copy the patches you want to use
4149: or update from the <code class="filename">work/.newpatches</code>
4150: directory to <code class="filename">patches/</code>.</p>
4151: <p>When you have finished a package, remember to generate
4152: the checksums for the patch files by using the <span><strong class="command">make
1.90 ! rillig 4153: makepatchsum</strong></span> command, see <a href="#components.distinfo" title="10.2. distinfo">Section 10.2, “<code class="filename">distinfo</code>”</a>.</p>
1.87 wiz 4154: <p>When adding a patch that corrects a problem in the
4155: distfile (rather than e.g. enforcing pkgsrc's view of where
4156: man pages should go), send the patch as a bug report to the
4157: maintainer. This benefits non-pkgsrc users of the package,
4158: and usually makes it possible to remove the patch in future
4159: version.</p>
4160: <p>If you want to share patches between multiple packages
4161: in pkgsrc, e.g. because they use the same distfiles, set
4162: <code class="varname">PATCHDIR</code> to the path where the patch files
4163: can be found, e.g.:</p>
4164: <pre class="programlisting">
4165: PATCHDIR= ${.CURDIR}/../xemacs/patches
4166: </pre>
1.75 rillig 4167: <p>Patch files that are distributed by the author or other
1.87 wiz 4168: maintainers can be listed in
4169: <code class="varname">PATCHFILES</code>.</p>
4170: <p>If it is desired to store any patches that should not be
4171: committed into pkgsrc, they can be kept outside the pkgsrc
4172: tree in the <code class="filename">$LOCALPATCHES</code> directory. The
4173: directory tree there is expected to have the same
4174: “<span class="quote">category/package</span>” structure as pkgsrc, and
4175: patches are expected to be stored inside these dirs (also
4176: known as <code class="filename">$LOCALPATCHES/$PKGPATH</code>). For
4177: example, if you want to keep a private patch for
4178: <code class="filename">pkgsrc/graphics/png</code>, keep it in
4179: <code class="filename">$LOCALPATCHES/graphics/png/mypatch</code>. All
4180: files in the named directory are expected to be patch files,
4181: and <span class="emphasis"><em>they are applied after pkgsrc patches are
4182: applied</em></span>.</p>
1.85 jmmv 4183: <div class="sect2" lang="en">
4184: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 4185: <a name="components.patches.guidelines"></a>10.3.1. Patching guidelines</h3></div></div></div>
1.85 jmmv 4186: <p>When fixing a portability issue in the code do not use
4187: preprocessor magic to check for the current operating system nor
4188: platform. Doing so hurts portability to other platforms because
4189: the OS-specific details are not abstracted appropriately.</p>
4190: <p>The general rule to follow is: instead of checking for the
4191: operating system the application is being built on, check for the
4192: specific <span class="emphasis"><em>features</em></span> you need. For example,
4193: instead of assuming that kqueue is available under NetBSD and
4194: using the <code class="varname">__NetBSD__</code> macro to conditionalize
1.89 rillig 4195: kqueue support, add a check that detects kqueue itself —
1.85 jmmv 4196: yes, this generally involves patching the
4197: <span><strong class="command">configure</strong></span> script. There is absolutely nothing
4198: that prevents some OSes from adopting interfaces from other OSes
4199: (e.g. Linux implementing kqueue), something that the above checks
4200: cannot take into account.</p>
4201: <p>Of course, checking for features generally involves more
4202: work on the developer's side, but the resulting changes are
1.87 wiz 4203: cleaner and there are chances they will work on many other
1.85 jmmv 4204: platforms. Not to mention that there are higher chances of being
4205: later integrated into the mainstream sources. Remember:
4206: <span class="emphasis"><em>It doesn't work unless it is right!</em></span></p>
4207: <p>Some typical examples:</p>
4208: <div class="table">
1.90 ! rillig 4209: <a name="patch-examples"></a><p class="title"><b>Table 10.1. Patching examples</b></p>
1.89 rillig 4210: <table summary="Patching examples" border="1">
1.85 jmmv 4211: <colgroup>
4212: <col>
4213: <col>
4214: <col>
4215: </colgroup>
4216: <thead><tr>
4217: <th>Where</th>
4218: <th>Incorrect</th>
4219: <th>Correct</th>
4220: </tr></thead>
4221: <tbody>
4222: <tr>
4223: <td>configure script</td>
4224: <td>
4225: <pre class="programlisting">case ${target_os} in
1.87 wiz 4226: netbsd*) have_kvm=yes ;;
4227: *) have_kvm=no ;;
4228: esac</pre>
1.85 jmmv 4229: </td>
4230: <td>
4231: <pre class="programlisting">AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)</pre>
4232: </td>
4233: </tr>
4234: <tr>
4235: <td>C source file</td>
4236: <td>
4237: <pre class="programlisting">#if defined(__NetBSD__)
1.87 wiz 4238: # include <sys/event.h>
4239: #endif</pre>
1.85 jmmv 4240: </td>
4241: <td>
4242: <pre class="programlisting">#if defined(HAVE_SYS_EVENT_H)
1.87 wiz 4243: # include <sys/event.h>
4244: #endif</pre>
1.85 jmmv 4245: </td>
4246: </tr>
4247: <tr>
4248: <td>C source file</td>
4249: <td>
4250: <pre class="programlisting">int
1.87 wiz 4251: monitor_file(...)
4252: {
4253: #if defined(__NetBSD__)
4254: int fd = kqueue();
4255: ...
4256: #else
4257: ...
4258: #endif
4259: }</pre>
1.85 jmmv 4260: </td>
4261: <td>
4262: <pre class="programlisting">int
1.87 wiz 4263: monitor_file(...)
4264: {
4265: #if defined(HAVE_KQUEUE)
4266: int fd = kqueue();
4267: ...
4268: #else
4269: ...
4270: #endif
4271: }</pre>
1.85 jmmv 4272: </td>
4273: </tr>
4274: </tbody>
1.89 rillig 4275: </table>
1.85 jmmv 4276: </div>
1.89 rillig 4277: <p>For more information, please read the <span class="emphasis"><em>Making
1.85 jmmv 4278: packager-friendly software</em></span> article (<a href="http://www.onlamp.com/pub/a/onlamp/2005/03/31/packaging.html" target="_top">part
4279: 1</a>, <a href="http://www.oreillynet.com/pub/a/onlamp/2005/04/28/packaging2.html" target="_top">part
4280: 2</a>). It summarizes multiple details on how to make
4281: software easier to package; all the suggestions in it were
4282: collected from our experience in pkgsrc work, so they are possibly
4283: helpful when creating patches too.</p>
4284: </div>
4285: <div class="sect2" lang="en">
4286: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 4287: <a name="components.patches.feedback"></a>10.3.2. Feedback to the author</h3></div></div></div>
1.85 jmmv 4288: <p>Always, always, <span class="strong"><strong>always</strong></span>
4289: feed back any <span class="emphasis"><em>portability fixes</em></span> or
4290: improvements you do to a package to the mainstream developers.
4291: This is the only way to get their attention on portability issues
4292: and to ensure that future versions can be built out-of-the box on
4293: NetBSD. Furthermore, any user that gets newer distfiles will get
4294: the fixes straight from the packaged code.</p>
4295: <p>This generally involves cleaning up the patches as described
4296: in the following section (because sometimes the patches that are
4297: added to pkgsrc are quick hacks), filling bug reports in the
4298: appropriate trackers for the projects and working with the
4299: mainstream authors to accept your changes. It is
4300: <span class="emphasis"><em>extremely important</em></span> that you do it so that
4301: the packages in pkgsrc are kept simple and thus further changes
4302: can be done without much hassle.</p>
4303: <p>Support the idea of free software!</p>
4304: </div>
1.75 rillig 4305: </div>
4306: <div class="sect1" lang="en">
4307: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4308: <a name="other-mandatory-files"></a>10.4. Other mandatory files</h2></div></div></div>
1.75 rillig 4309: <div class="variablelist"><dl>
1.76 rillig 4310: <dt><span class="term"><code class="filename">DESCR</code></span></dt>
1.75 rillig 4311: <dd><p>A multi-line description of the piece of software. This should include
1.87 wiz 4312: any credits where they are due. Please bear in mind that others do not
4313: share your sense of humour (or spelling idiosyncrasies), and that others
4314: will read everything that you write here.</p></dd>
1.76 rillig 4315: <dt><span class="term"><code class="filename">PLIST</code></span></dt>
1.87 wiz 4316: <dd><p>This file governs the files that are installed on your
4317: system: all the binaries, manual pages, etc. There are other
4318: directives which may be entered in this file, to control the
4319: creation and deletion of directories, and the location of
1.90 ! rillig 4320: inserted files. See <a href="#plist" title="Chapter 12. PLIST issues">Chapter 12, <i>PLIST issues</i></a> for more
1.87 wiz 4321: information.</p></dd>
1.75 rillig 4322: </dl></div>
4323: </div>
4324: <div class="sect1" lang="en">
4325: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4326: <a name="components.optional"></a>10.5. Optional files</h2></div></div></div>
1.78 rillig 4327: <div class="sect2" lang="en">
4328: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 4329: <a name="components.optional.bin"></a>10.5.1. Files affecting the binary package</h3></div></div></div>
1.75 rillig 4330: <div class="variablelist"><dl>
1.76 rillig 4331: <dt><span class="term"><code class="filename">INSTALL</code></span></dt>
1.75 rillig 4332: <dd><p>This shell script is invoked twice by <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>.
1.87 wiz 4333: First time after package extraction and before files are
4334: moved in place, the second time after the files to install
4335: are moved in place. This can be used to do any custom
4336: procedures not possible with @exec commands in
4337: <code class="filename">PLIST</code>. See <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> and
1.90 ! rillig 4338: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_create</span>(1)</span></a> for more information. See also <a href="#files-and-dirs-outside-prefix" title="14.1. Files and directories outside the installation prefix">Section 14.1, “Files and directories outside the installation prefix”</a>.</p></dd>
1.76 rillig 4339: <dt><span class="term"><code class="filename">DEINSTALL</code></span></dt>
1.75 rillig 4340: <dd><p>This script is executed before and after any files are removed. It is
1.87 wiz 4341: this script's responsibility to clean up any additional messy details
4342: around the package's installation, since all pkg_delete knows is how to
4343: delete the files created in the original distribution.
4344: See <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a>
4345: and <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_create</span>(1)</span></a> for more information.</p></dd>
1.76 rillig 4346: <dt><span class="term"><code class="filename">MESSAGE</code></span></dt>
1.75 rillig 4347: <dd>
4348: <p>This file is displayed after installation of the package.
1.87 wiz 4349: Useful for things like legal notices on almost-free
4350: software and hints for updating config files after
4351: installing modules for apache, PHP etc.
4352: Please note that you can modify variables in it easily by using
4353: <code class="varname">MESSAGE_SUBST</code> in the package's
4354: <code class="filename">Makefile</code>:</p>
1.75 rillig 4355: <pre class="programlisting">
1.87 wiz 4356: MESSAGE_SUBST+= SOMEVAR="somevalue"
4357: </pre>
1.75 rillig 4358: <p>replaces "${SOMEVAR}" with “<span class="quote">somevalue</span>” in
1.87 wiz 4359: <code class="filename">MESSAGE</code>. By default, substitution is
4360: performed for <code class="varname">PKGNAME</code>,
4361: <code class="varname">PKGBASE</code>, <code class="varname">PREFIX</code>,
4362: <code class="varname">LOCALBASE</code>, <code class="varname">X11PREFIX</code>,
4363: <code class="varname">X11BASE</code>,
4364: <code class="varname">PKG_SYSCONFDIR</code>,
4365: <code class="varname">ROOT_GROUP</code>, and
4366: <code class="varname">ROOT_GROUP</code>.</p>
4367: <p>You can display a different or additional files by
4368: setting the <code class="varname">MESSAGE_SRC</code> variable. Its
4369: default is <code class="filename">MESSAGE</code>, if the file
4370: exists.</p>
1.75 rillig 4371: </dd>
1.78 rillig 4372: <dt><span class="term"><code class="filename">ALTERNATIVES</code></span></dt>
4373: <dd><p>FIXME: There is no documentation on the
4374: alternatives framework.</p></dd>
4375: </dl></div>
4376: </div>
4377: <div class="sect2" lang="en">
4378: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 4379: <a name="components.optional.build"></a>10.5.2. Files affecting the build process</h3></div></div></div>
1.78 rillig 4380: <div class="variablelist"><dl>
4381: <dt><span class="term"><code class="filename">Makefile.common</code></span></dt>
4382: <dd><p>This file contains arbitrary things that could
4383: also go into a <code class="filename">Makefile</code>, but its purpose is
4384: to be used by more than one package. This file should only be
4385: used when the packages that will use the file are known in
4386: advance. For other purposes it is often better to write a
4387: <code class="filename">*.mk</code> file and give it a good name that
4388: describes what it does.</p></dd>
4389: <dt><span class="term"><code class="filename">buildlink3.mk</code></span></dt>
4390: <dd><p>This file contains the dependency information
1.90 ! rillig 4391: for the buildlink3 framework (see <a href="#buildlink" title="Chapter 13. Buildlink methodology">Chapter 13, <i>Buildlink methodology</i></a>).</p></dd>
1.78 rillig 4392: <dt><span class="term"><code class="filename">hacks.mk</code></span></dt>
4393: <dd><p>This file contains workarounds for compiler bugs
4394: and similar things. It is included automatically by the pkgsrc
4395: infrastructure, so you don't need an extra
4396: <code class="literal">.include</code> line for
4397: it.</p></dd>
4398: <dt><span class="term"><code class="filename">options.mk</code></span></dt>
4399: <dd><p>This file contains the code for the
1.90 ! rillig 4400: package-specific options (see <a href="#options" title="Chapter 15. Options handling">Chapter 15, <i>Options handling</i></a>) that can be
1.78 rillig 4401: selected by the user. If a package has only one or two options,
4402: it is equally acceptable to put the code directly into the
4403: <code class="filename">Makefile</code>.</p></dd>
4404: </dl></div>
4405: </div>
4406: <div class="sect2" lang="en">
4407: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 4408: <a name="components.optional.none"></a>10.5.3. Files affecting nothing at all</h3></div></div></div>
1.78 rillig 4409: <div class="variablelist"><dl>
4410: <dt><span class="term"><code class="filename">README*</code></span></dt>
4411: <dd><p>These files do not take place in the creation of
4412: a package and thus are purely informative to the package
4413: developer.</p></dd>
4414: <dt><span class="term"><code class="filename">TODO</code></span></dt>
4415: <dd><p>This file contains things that need to be done
4416: to make the package even
4417: better.</p></dd>
1.75 rillig 4418: </dl></div>
4419: </div>
1.78 rillig 4420: </div>
1.75 rillig 4421: <div class="sect1" lang="en">
4422: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4423: <a name="work-dir"></a>10.6. <code class="filename">work*</code></h2></div></div></div>
1.75 rillig 4424: <p>When you type <span><strong class="command">make</strong></span>, the distribution files are
1.87 wiz 4425: unpacked into the directory denoted by
4426: <code class="varname">WRKDIR</code>. It can be removed by running
4427: <span><strong class="command">make clean</strong></span>. Besides the sources, this
4428: directory is also used to keep various timestamp files.
4429: The directory gets <span class="emphasis"><em>removed completely</em></span> on clean.
4430: The default is <code class="filename">${.CURDIR}/work</code>
4431: or <code class="filename">${.CURDIR}/work.${MACHINE_ARCH}</code>
4432: if <code class="varname">OBJMACHINE</code> is set.</p>
1.75 rillig 4433: </div>
4434: <div class="sect1" lang="en">
4435: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4436: <a name="files-dir"></a>10.7. <code class="filename">files/*</code></h2></div></div></div>
1.75 rillig 4437: <p>If you have any files that you wish to be placed in the package prior
1.87 wiz 4438: to configuration or building, you could place these files here and use
4439: a <span><strong class="command">${CP}</strong></span> command in the
4440: “<span class="quote">pre-configure</span>” target to achieve
4441: this. Alternatively, you could simply diff the file against
4442: <code class="filename">/dev/null</code> and use the patch mechanism to manage
4443: the creation of this file.</p>
4444: <p>If you want to share files in this way with other
4445: packages, set the <code class="varname">FILESDIR</code> variable to point
4446: to the other package's <code class="filename">files</code> directory,
4447: e.g.:</p>
4448: <pre class="programlisting">
4449: FILESDIR=${.CURDIR}/../xemacs/files
4450: </pre>
1.75 rillig 4451: </div>
4452: </div>
4453: <div class="chapter" lang="en">
4454: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 4455: <a name="makefile"></a>Chapter 11. Programming in <code class="filename">Makefile</code>s</h2></div></div></div>
1.75 rillig 4456: <div class="toc">
4457: <p><b>Table of Contents</b></p>
4458: <dl>
1.90 ! rillig 4459: <dt><span class="sect1"><a href="#makefile.variables">11.1. <code class="filename">Makefile</code> variables</a></span></dt>
! 4460: <dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">11.1.1. Naming conventions</a></span></dt></dl></dd>
! 4461: <dt><span class="sect1"><a href="#makefile.code">11.2. Code snippets</a></span></dt>
! 4462: <dd><dl>
! 4463: <dt><span class="sect2"><a href="#adding-to-list">11.2.1. Adding things to a list</a></span></dt>
! 4464: <dt><span class="sect2"><a href="#converting-internal-to-external">11.2.2. Converting an internal list into an external list</a></span></dt>
! 4465: <dt><span class="sect2"><a href="#passing-variable-to-shell">11.2.3. Passing variables to a shell command</a></span></dt>
! 4466: <dt><span class="sect2"><a href="#quoting-guideline">11.2.4. Quoting guideline</a></span></dt>
! 4467: <dt><span class="sect2"><a href="#bsd-make-bug-workaround">11.2.5. Workaround for a bug in BSD Make</a></span></dt>
1.75 rillig 4468: </dl></dd>
4469: </dl>
4470: </div>
1.76 rillig 4471: <p>Pkgsrc consists of many <code class="filename">Makefile</code> fragments,
1.75 rillig 4472: each of which forms a well-defined part of the pkgsrc system. Using
4473: the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> system as a programming language for a big system
4474: like pkgsrc requires some discipline to keep the code correct and
4475: understandable.</p>
1.76 rillig 4476: <p>The basic ingredients for <code class="filename">Makefile</code>
1.75 rillig 4477: programming are variables (which are actually macros) and shell
4478: commands. Among these shell commands may even be more complex ones
4479: like <a href="http://netbsd.gw.com/cgi-bin/man-cgi?awk+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">awk</span>(1)</span></a> programs. To make sure that every shell command runs
4480: as intended it is necessary to quote all variables correctly when they
4481: are used.</p>
4482: <p>This chapter describes some patterns, that appear quite often in
1.76 rillig 4483: <code class="filename">Makefile</code>s, including the pitfalls that come along
1.75 rillig 4484: with them.</p>
4485: <div class="sect1" lang="en">
4486: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4487: <a name="makefile.variables"></a>11.1. <code class="filename">Makefile</code> variables</h2></div></div></div>
1.76 rillig 4488: <p><code class="filename">Makefile</code> variables contain strings that
1.75 rillig 4489: can be processed using the five operators ``='', ``+='', ``?='',
4490: ``:='', and ``!='', which are described in the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> man
4491: page.</p>
4492: <p>When a variable's value is parsed from a
1.76 rillig 4493: <code class="filename">Makefile</code>, the hash character ``#'' and the
1.75 rillig 4494: backslash character ``\'' are handled specially. If a backslash is
4495: followed by a newline, any whitespace immediately in front of the
4496: backslash, the backslash, the newline, and any whitespace
4497: immediately behind the newline are replaced with a single space. A
4498: backslash character and an immediately following hash character are
4499: replaced with a single hash character. Otherwise, the backslash is
4500: passed as is. In a variable assignment, any hash character that is
4501: not preceded by a backslash starts a comment that continues upto the
4502: end of the logical line.</p>
4503: <p><span class="emphasis"><em>Note:</em></span> Because of this parsing algorithm
4504: the only way to create a variable consisting of a single backslash
4505: is using the ``!='' operator, for example: <code class="varname">BACKSLASH!=echo "\\"</code>.</p>
4506: <p>So far for defining variables. The other thing you can do with
4507: variables is evaluating them. A variable is evaluated when it is
4508: part of the right side of the ``:='' or the ``!='' operator, or
4509: directly before executing a shell command which the variable is part
4510: of. In all other cases, <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> performs lazy evaluation, that
4511: is, variables are not evaluated until there's no other way. The
4512: ``modifiers'' mentioned in the man page also evaluate the
4513: variable.</p>
4514: <p>Some of the modifiers split the string into words and then
4515: operate on the words, others operate on the string as a whole. When
4516: a string is split into words, it is split as you would expect
4517: it from <a href="http://netbsd.gw.com/cgi-bin/man-cgi?sh+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">sh</span>(1)</span></a>.</p>
1.89 rillig 4518: <p>No rule without exception—the <span><strong class="command">.for</strong></span>
1.75 rillig 4519: loop does not follow the shell quoting rules but splits at sequences
4520: of whitespace.</p>
4521: <p>There are several types of variables that should be handled
4522: differently. Strings and two types of lists.</p>
4523: <div class="itemizedlist"><ul type="disc">
4524: <li><p><span class="emphasis"><em>Strings</em></span> can contain arbitrary
4525: characters. Nevertheless, you should restrict yourself to only
4526: using printable characters. Examples are
4527: <code class="varname">PREFIX</code> and
4528: <code class="varname">COMMENT</code>.</p></li>
4529: <li><p><span class="emphasis"><em>Internal lists</em></span> are lists that
4530: are never exported to any shell command. Their elements are
4531: separated by whitespace. Therefore, the elements themselves cannot
4532: have embedded whitespace. Any other characters are allowed.
4533: Internal lists can be used in <span><strong class="command">.for</strong></span> loops.
4534: Examples are <code class="varname">DEPENDS</code> and
4535: <code class="varname">BUILD_DEPENDS</code>.</p></li>
4536: <li><p><span class="emphasis"><em>External lists</em></span> are lists that
4537: may be exported to a shell command. Their elements can contain any
4538: characters, including whitespace. That's why they cannot be used
4539: in <span><strong class="command">.for</strong></span> loops. Examples are
4540: <code class="varname">DISTFILES</code> and
4541: <code class="varname">MASTER_SITES</code>.</p></li>
4542: </ul></div>
4543: <div class="sect2" lang="en">
4544: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 4545: <a name="makefile.variables.names"></a>11.1.1. Naming conventions</h3></div></div></div>
1.75 rillig 4546: <div class="itemizedlist"><ul type="disc">
4547: <li><p>All variable names starting with an underscore
4548: are reserved for use by the pkgsrc infrastructure. They shall
4549: not be used by package
1.76 rillig 4550: <code class="filename">Makefile</code>s.</p></li>
1.75 rillig 4551: <li><p>In <span><strong class="command">.for</strong></span> loops you should use
4552: lowercase variable names for the iteration
4553: variables.</p></li>
4554: <li><p>All list variables should have a ``plural''
4555: name, e.g. <code class="varname">PKG_OPTIONS</code> or
4556: <code class="varname">DISTFILES</code>.</p></li>
4557: </ul></div>
4558: </div>
4559: </div>
4560: <div class="sect1" lang="en">
4561: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4562: <a name="makefile.code"></a>11.2. Code snippets</h2></div></div></div>
1.75 rillig 4563: <p>This section presents you with some code snippets you should
4564: use in your own code. If you don't find anything appropriate here,
4565: you should test your code and add it here.</p>
4566: <div class="sect2" lang="en">
4567: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 4568: <a name="adding-to-list"></a>11.2.1. Adding things to a list</h3></div></div></div>
1.75 rillig 4569: <pre class="programlisting">
4570: STRING= foo * bar `date`
4571: INT_LIST= # empty
4572: ANOTHER_INT_LIST= apache-[0-9]*:../../www/apache
4573: EXT_LIST= # empty
4574: ANOTHER_EXT_LIST= a=b c=d
1.1 grant 4575:
1.75 rillig 4576: INT_LIST+= ${STRING} # 1
4577: INT_LIST+= ${ANOTHER_INT_LIST} # 2
4578: EXT_LIST+= ${STRING:Q} # 3
4579: EXT_LIST+= ${ANOTHER_EXT_LIST} # 4
1.1 grant 4580: </pre>
1.75 rillig 4581: <p>When you add a string to an external list (example 3), it
4582: must be quoted. In all other cases, you must not add a quoting
4583: level. You must not merge internal and external lists, unless you
4584: are sure that all entries are correctly interpreted in both
4585: lists.</p>
4586: </div>
4587: <div class="sect2" lang="en">
4588: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 4589: <a name="converting-internal-to-external"></a>11.2.2. Converting an internal list into an external list</h3></div></div></div>
1.75 rillig 4590: <pre class="programlisting">
4591: EXT_LIST= # empty
4592: .for i in ${INT_LIST}
4593: EXT_LIST+= ${i:Q}""
4594: .endfor
1.1 grant 4595: </pre>
1.75 rillig 4596: <p>This code converts the internal list
4597: <code class="varname">INT_LIST</code> into the external list
4598: <code class="varname">EXT_LIST</code>. As the elements of an internal list
4599: are unquoted they must be quoted here. The reason for appending
4600: <code class="varname">""</code> is explained below.</p>
4601: </div>
4602: <div class="sect2" lang="en">
4603: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 4604: <a name="passing-variable-to-shell"></a>11.2.3. Passing variables to a shell command</h3></div></div></div>
1.79 rillig 4605: <p>Sometimes you may want to print an arbitrary string. There
4606: are many ways to get it wrong and only few that can handle every
4607: nastiness.</p>
1.75 rillig 4608: <pre class="programlisting">
4609: STRING= foo bar < > * `date` $$HOME ' "
4610: EXT_LIST= string=${STRING:Q} x=second\ item
1.1 grant 4611:
1.75 rillig 4612: all:
4613: echo ${STRING} # 1
4614: echo "${STRING}" # 2
4615: echo "${STRING:Q}" # 3
4616: echo ${STRING:Q} # 4
4617: echo x${STRING:Q} | sed 1s,.,, # 5
1.79 rillig 4618: printf "%s\\n" ${STRING:Q}"" # 6
1.75 rillig 4619: env ${EXT_LIST} /bin/sh -c 'echo "$$string"; echo "$$x"'
1.1 grant 4620: </pre>
1.75 rillig 4621: <p>Example 1 leads to a syntax error in the shell, as the
4622: characters are just copied.</p>
4623: <p>Example 2 leads to a syntax error too, and if you leave out
4624: the last " character from <code class="varname">${STRING}</code>,
4625: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?date+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">date</span>(1)</span></a> will be executed. The <code class="varname">$HOME</code> shell
4626: variable would be evaluated, too.</p>
4627: <p>Example 3 outputs each space character preceded by a
4628: backslash (or not), depending on the implementation of the
4629: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">echo</span>(1)</span></a> command.</p>
4630: <p>Example 4 handles correctly every string that does not start
4631: with a dash. In that case, the result depends on the
4632: implementation of the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">echo</span>(1)</span></a> command. As long as you can
4633: guarantee that your input does not start with a dash, this form is
4634: appropriate.</p>
4635: <p>Example 5 handles even the case of a leading dash
4636: correctly.</p>
1.79 rillig 4637: <p>Example 6 also works with every string and is the
4638: light-weight solution, since it does not involve a pipe, which has
4639: its own problems.</p>
1.75 rillig 4640: <p>The <code class="varname">EXT_LIST</code> does not need to be quoted
4641: because the quoting has already been done when adding elements to
4642: the list.</p>
4643: <p>As internal lists shall not be passed to the shell, there is
4644: no example for it.</p>
4645: </div>
4646: <div class="sect2" lang="en">
4647: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 4648: <a name="quoting-guideline"></a>11.2.4. Quoting guideline</h3></div></div></div>
1.75 rillig 4649: <p>There are many possible sources of wrongly quoted variables.
4650: This section lists some of the commonly known ones.</p>
4651: <div class="itemizedlist"><ul type="disc">
4652: <li>
4653: <p>Whenever you use the value of a list, think
4654: about what happens to leading or trailing whitespace. If the
4655: list is a well-formed shell expression, you can apply the
4656: <code class="varname">:M*</code> modifier to strip leading and trailing
4657: whitespace from each word. The <code class="varname">:M</code> operator
4658: first splits its argument according to the rules of the shell,
4659: and then creates a new list consisting of all words that match
4660: the shell glob expression <code class="varname">*</code>, that is: all.
4661: One class of situations where this is needed is when adding a
4662: variable like <code class="varname">CPPFLAGS</code> to
4663: <code class="varname">CONFIGURE_ARGS</code>. If the configure script
4664: invokes other configure scripts, it strips the leading and
4665: trailing whitespace from the variable and then passes it to the
4666: other configure scripts. But these configure scripts expect the
4667: (child) <code class="varname">CPPFLAGS</code> variable to be the same as
4668: the parent <code class="varname">CPPFLAGS</code>. That's why we better
4669: pass the <code class="varname">CPPFLAGS</code> value properly trimmed. And
4670: here is how we do it:</p>
4671: <pre class="programlisting">
4672: CPPFLAGS= # empty
4673: CPPFLAGS+= -Wundef -DPREFIX=\"${PREFIX:Q}\"
4674: CPPFLAGS+= ${MY_CPPFLAGS}
1.1 grant 4675:
1.75 rillig 4676: CONFIGURE_ARGS+= CPPFLAGS=${CPPFLAGS:M*:Q}
1.1 grant 4677:
1.75 rillig 4678: all:
4679: echo x${CPPFLAGS:Q}x # leading and trailing whitespace
4680: echo x${CONFIGURE_ARGS}x # properly trimmed
1.1 grant 4681: </pre>
1.75 rillig 4682: </li>
4683: <li><p>The example above contains one bug: The
4684: <code class="varname">${PREFIX}</code> is a properly quoted shell
4685: expression, but there is the C compiler after it, which also
4686: expects a properly quoted string (this time in C syntax). The
4687: version above is therefore only correct if
4688: <code class="varname">${PREFIX}</code> does not have embedded backslashes
4689: or double quotes. If you want to allow these, you have to add
4690: another layer of quoting to each variable that is used as a C
4691: string literal. You cannot use the <code class="varname">:Q</code>
4692: operator for it, as this operator only works for the
4693: shell.</p></li>
4694: <li>
4695: <p>Whenever a variable can be empty, the
4696: <code class="varname">:Q</code> operator can have surprising results. Here
4697: are two completely different cases which can be solved with the
4698: same trick.</p>
4699: <pre class="programlisting">
4700: EMPTY= # empty
4701: empty_test:
4702: for i in a ${EMPTY:Q} c; do \
4703: echo "$$i"; \
4704: done
1.1 grant 4705:
1.75 rillig 4706: for_test:
4707: .for i in a:\ a:\test.txt
4708: echo ${i:Q}
4709: echo "foo"
4710: .endfor
1.1 grant 4711: </pre>
1.75 rillig 4712: <p>The first example will only print two of the three lines
4713: we might have expected. This is because
4714: <code class="varname">${EMPTY:Q}</code> expands to the empty string, which
4715: the shell cannot see. The workaround is to write
4716: <code class="varname">${EMPTY:Q}""</code>. This pattern can be often found
4717: as <code class="varname">${TEST} -z ${VAR:Q}</code> or as <code class="varname">${TEST}
4718: -f ${FNAME:Q}</code> (both of these are wrong).</p>
4719: <p>The second example will only print three lines instead of
4720: four. The first line looks like <code class="varname">a:\ echo foo</code>.
4721: This is because the backslash of the value
4722: <code class="varname">a:\</code> is interpreted as a line-continuation by
4723: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>, which makes the second line the arguments of the
4724: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?echo+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">echo</span>(1)</span></a> command from the first line. To avoid this, write
4725: <code class="varname">${i:Q}""</code>.</p>
4726: </li>
4727: </ul></div>
4728: </div>
4729: <div class="sect2" lang="en">
4730: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 4731: <a name="bsd-make-bug-workaround"></a>11.2.5. Workaround for a bug in BSD Make</h3></div></div></div>
1.75 rillig 4732: <p>The pkgsrc bmake program does not handle the following
4733: assignment correctly. In case <code class="varname">_othervar_</code>
4734: contains a ``-'' character, one of the closing braces is included
4735: in <code class="varname">${VAR}</code> after this code executes.</p>
4736: <pre class="programlisting">
4737: VAR:= ${VAR:N${_othervar_:C/-//}}
1.1 grant 4738: </pre>
1.75 rillig 4739: <p>For a more complex code snippet and a workaround, see the
1.76 rillig 4740: package <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/regress/make-quoting/README.html" target="_top"><code class="filename">regress/make-quoting</code></a>, testcase
1.75 rillig 4741: <code class="varname">bug1</code>.</p>
4742: </div>
4743: </div>
4744: </div>
4745: <div class="chapter" lang="en">
4746: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 4747: <a name="plist"></a>Chapter 12. PLIST issues</h2></div></div></div>
1.75 rillig 4748: <div class="toc">
4749: <p><b>Table of Contents</b></p>
4750: <dl>
1.90 ! rillig 4751: <dt><span class="sect1"><a href="#rcs-id">12.1. RCS ID</a></span></dt>
! 4752: <dt><span class="sect1"><a href="#automatic-plist-generation">12.2. Semi-automatic <code class="filename">PLIST</code> generation</a></span></dt>
! 4753: <dt><span class="sect1"><a href="#print-PLIST">12.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></a></span></dt>
! 4754: <dt><span class="sect1"><a href="#plist.misc">12.4. Variable substitution in PLIST</a></span></dt>
! 4755: <dt><span class="sect1"><a href="#manpage-compression">12.5. Man page compression</a></span></dt>
! 4756: <dt><span class="sect1"><a href="#using-PLIST_SRC">12.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></a></span></dt>
! 4757: <dt><span class="sect1"><a href="#platform-specific-plist">12.7. Platform-specific and differing PLISTs</a></span></dt>
! 4758: <dt><span class="sect1"><a href="#faq.common-dirs">12.8. Sharing directories between packages</a></span></dt>
1.75 rillig 4759: </dl>
4760: </div>
1.87 wiz 4761: <p>The <code class="filename">PLIST</code> file contains a package's
4762: “<span class="quote">packing list</span>”, i.e. a list of files that belong to
4763: the package (relative to the <code class="filename">${PREFIX}</code>
4764: directory it's been installed in) plus some additional statements
4765: - see the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_create+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_create</span>(1)</span></a> man page for a full list.
4766: This chapter addresses some issues that need attention when
4767: dealing with the <code class="filename">PLIST</code> file (or files, see
4768: below!).</p>
1.75 rillig 4769: <div class="sect1" lang="en">
4770: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4771: <a name="rcs-id"></a>12.1. RCS ID</h2></div></div></div>
1.87 wiz 4772: <p>Be sure to add a RCS ID line as the first thing in any
4773: <code class="filename">PLIST</code> file you write:</p>
1.75 rillig 4774: <pre class="programlisting">
1.87 wiz 4775: @comment $NetBSD$
4776: </pre>
1.75 rillig 4777: </div>
4778: <div class="sect1" lang="en">
4779: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4780: <a name="automatic-plist-generation"></a>12.2. Semi-automatic <code class="filename">PLIST</code> generation</h2></div></div></div>
1.75 rillig 4781: <p>You can use the <span><strong class="command">make print-PLIST</strong></span> command
1.87 wiz 4782: to output a PLIST that matches any new files since the package
1.90 ! rillig 4783: was extracted. See <a href="#build.helpful-targets" title="16.17. Other helpful targets">Section 16.17, “Other helpful targets”</a> for
1.87 wiz 4784: more information on this target.</p>
1.75 rillig 4785: </div>
4786: <div class="sect1" lang="en">
4787: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4788: <a name="print-PLIST"></a>12.3. Tweaking output of <span><strong class="command">make print-PLIST</strong></span></h2></div></div></div>
1.87 wiz 4789: <p>If you have used any of the *-dirs packages, as explained in
1.90 ! rillig 4790: <a href="#faq.common-dirs" title="12.8. Sharing directories between packages">Section 12.8, “Sharing directories between packages”</a>, you may have noticed that
1.87 wiz 4791: <span><strong class="command">make print-PLIST</strong></span> outputs a set of
4792: <code class="varname">@comment</code>s instead of real
4793: <code class="varname">@dirrm</code> lines. You can also do this for
4794: specific directories and files, so that the results of that
4795: command are very close to reality. This helps <span class="emphasis"><em>a
4796: lot</em></span> during the update of packages.</p>
4797: <p>The <code class="varname">PRINT_PLIST_AWK</code> variable takes a set
4798: of AWK patterns and actions that are used to filter the output of
4799: print-PLIST. You can <span class="emphasis"><em>append</em></span> any chunk of AWK
4800: scripting you like to it, but be careful with quoting.</p>
4801: <p>For example, to get all files inside the
4802: <code class="filename">libdata/foo</code> directory removed from the
4803: resulting PLIST:</p>
4804: <pre class="programlisting">
4805: PRINT_PLIST_AWK+= /^libdata\/foo/ { next; }
4806: </pre>
4807: <p>And to get all the <code class="varname">@dirrm</code> lines referring
4808: to a specific (shared) directory converted to
4809: <code class="varname">@comment</code>s:</p>
1.75 rillig 4810: <pre class="programlisting">
1.87 wiz 4811: PRINT_PLIST_AWK+= /^@dirrm share\/specific/ { print "@comment " $$0; next; }
4812: </pre>
1.75 rillig 4813: </div>
4814: <div class="sect1" lang="en">
4815: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4816: <a name="plist.misc"></a>12.4. Variable substitution in PLIST</h2></div></div></div>
1.87 wiz 4817: <p>A number of variables are substituted automatically in
4818: PLISTs when a package is installed on a system. This includes the
4819: following variables:</p>
1.75 rillig 4820: <div class="variablelist"><dl>
4821: <dt><span class="term"><code class="varname">${MACHINE_ARCH}</code>, <code class="varname">${MACHINE_GNU_ARCH}</code></span></dt>
4822: <dd>
4823: <p>Some packages like emacs and perl embed information
1.87 wiz 4824: about which architecture they were built on into the
4825: pathnames where they install their files. To handle this
4826: case, PLIST will be preprocessed before actually used, and
4827: the symbol
4828: “<span class="quote"><code class="varname">${MACHINE_ARCH}</code></span>” will be
4829: replaced by what <span><strong class="command">uname -p</strong></span> gives. The
4830: same is done if the string
4831: <code class="varname">${MACHINE_GNU_ARCH}</code> is embedded in
4832: PLIST somewhere - use this on packages that have GNU
4833: autoconf-created configure scripts.</p>
1.75 rillig 4834: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
4835: <h3 class="title">Legacy note</h3>
4836: <p>There used to be a symbol
1.87 wiz 4837: “<span class="quote"><code class="varname">$ARCH</code></span>” that
4838: was replaced by the output of <span><strong class="command">uname
4839: -m</strong></span>, but that's no longer supported and has
4840: been removed.</p>
1.75 rillig 4841: </div>
4842: </dd>
4843: <dt><span class="term"><code class="varname">${OPSYS}</code>, <code class="varname">${LOWER_OPSYS}</code>, <code class="varname">${OS_VERSION}</code></span></dt>
4844: <dd>
4845: <p>Some packages want to embed the OS name and version
1.87 wiz 4846: into some paths. To do this, use these variables in the
4847: <code class="filename">PLIST</code>:
4848: </p>
1.75 rillig 4849: <div class="itemizedlist"><ul type="disc">
4850: <li><p><code class="varname">${OPSYS}</code> - output of “<span class="quote"><span><strong class="command">uname -s</strong></span></span>”</p></li>
4851: <li><p><code class="varname">${LOWER_OPSYS}</code> - lowercase common name (eg. “<span class="quote">solaris</span>”)</p></li>
4852: <li><p><code class="varname">${OS_VERSION}</code> - “<span class="quote"><span><strong class="command">uname -r</strong></span></span>”</p></li>
4853: </ul></div>
4854: </dd>
4855: </dl></div>
1.87 wiz 4856: <p>For a complete list of values which are replaced by
4857: default, please look in <code class="filename">bsd.pkg.mk</code> (and
4858: search for <code class="varname">PLIST_SUBST</code>).</p>
4859: <p>If you want to change other variables not listed above, you
4860: can add variables and their expansions to this variable in the
1.90 ! rillig 4861: following way, similar to <code class="varname">MESSAGE_SUBST</code> (see <a href="#components.optional" title="10.5. Optional files">Section 10.5, “Optional files”</a>):</p>
1.75 rillig 4862: <pre class="programlisting">
1.87 wiz 4863: PLIST_SUBST+= SOMEVAR="somevalue"
4864: </pre>
1.75 rillig 4865: <p>This replaces all occurrences of “<span class="quote">${SOMEVAR}</span>”
1.87 wiz 4866: in the <code class="filename">PLIST</code> with
4867: “<span class="quote">somevalue</span>”.</p>
1.75 rillig 4868: </div>
4869: <div class="sect1" lang="en">
4870: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4871: <a name="manpage-compression"></a>12.5. Man page compression</h2></div></div></div>
1.75 rillig 4872: <p>Man pages should be installed in compressed form if
1.87 wiz 4873: <code class="varname">MANZ</code> is set (in <code class="filename">bsd.own.mk</code>),
4874: and uncompressed otherwise. To handle this in the
4875: <code class="filename">PLIST</code> file, the suffix “<span class="quote">.gz</span>” is
4876: appended/removed automatically for man pages according to
4877: <code class="varname">MANZ</code> and <code class="varname">MANCOMPRESSED</code> being set
4878: or not, see above for details. This modification of the
4879: <code class="filename">PLIST</code> file is done on a copy of it, not
4880: <code class="filename">PLIST</code> itself.</p>
1.75 rillig 4881: </div>
4882: <div class="sect1" lang="en">
4883: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4884: <a name="using-PLIST_SRC"></a>12.6. Changing PLIST source with <code class="varname">PLIST_SRC</code></h2></div></div></div>
1.76 rillig 4885: <p>To use one or more files as source for the <code class="filename">PLIST</code> used
1.87 wiz 4886: in generating the binary package, set the variable
4887: <code class="varname">PLIST_SRC</code> to the names of that file(s).
4888: The files are later concatenated using <a href="http://netbsd.gw.com/cgi-bin/man-cgi?cat+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">cat</span>(1)</span></a>, and the order of things is
4889: important. The default for <code class="varname">PLIST_SRC</code> is
4890: <code class="filename">${PKGDIR}/PLIST</code>.</p>
1.75 rillig 4891: </div>
4892: <div class="sect1" lang="en">
4893: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4894: <a name="platform-specific-plist"></a>12.7. Platform-specific and differing PLISTs</h2></div></div></div>
1.75 rillig 4895: <p>Some packages decide to install a different set of files based on
1.87 wiz 4896: the operating system being used. These differences can be
4897: automatically handled by using the following files:</p>
1.75 rillig 4898: <div class="itemizedlist"><ul type="disc">
1.76 rillig 4899: <li><p><code class="filename">PLIST.common</code></p></li>
4900: <li><p><code class="filename">PLIST.${OPSYS}</code></p></li>
4901: <li><p><code class="filename">PLIST.${MACHINE_ARCH}</code></p></li>
4902: <li><p><code class="filename">PLIST.${OPSYS}-${MACHINE_ARCH}</code></p></li>
4903: <li><p><code class="filename">PLIST.common_end</code></p></li>
1.75 rillig 4904: </ul></div>
4905: </div>
4906: <div class="sect1" lang="en">
4907: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 4908: <a name="faq.common-dirs"></a>12.8. Sharing directories between packages</h2></div></div></div>
1.87 wiz 4909: <p>A “<span class="quote">shared directory</span>” is a directory where
4910: multiple (and unrelated) packages install files. These
4911: directories are problematic because you have to add special tricks
4912: in the PLIST to conditionally remove them, or have some
4913: centralized package handle them.</p>
4914: <p>Within pkgsrc, you'll find both approaches. If a directory
4915: is shared by a few unrelated packages, it's often not worth to add
4916: an extra package to remove it. Therefore, one simply does:</p>
4917: <pre class="programlisting">
4918: @unexec ${RMDIR} %D/path/to/shared/directory 2>/dev/null || ${TRUE}
4919: </pre>
4920: <p>in the PLISTs of all affected packages, instead of the
4921: regular "@dirrm" line.</p>
4922: <p>However, if the directory is shared across many packages, two
4923: different solutions are available:</p>
1.75 rillig 4924: <div class="orderedlist"><ol type="1">
1.87 wiz 4925: <li><p>If the packages have a common dependency, the directory
4926: can be removed in that. For example, see
4927: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/textproc/scrollkeeper/README.html" target="_top"><code class="filename">textproc/scrollkeeper</code></a>, which
4928: removes the shared directory
4929: <code class="filename">share/omf</code>.</p></li>
4930: <li><p>If the packages using the directory are not related at
4931: all (they have no common dependencies), a *-dirs package is
4932: used.</p></li>
1.75 rillig 4933: </ol></div>
1.87 wiz 4934: <p>From now on, we'll discuss the second solution. To get an
4935: idea of the *-dirs packages available, issue:</p>
1.75 rillig 4936: <pre class="programlisting">
1.87 wiz 4937: <code class="prompt">%</code> cd .../pkgsrc
4938: <code class="prompt">%</code> ls -d */*-dirs
4939: </pre>
4940: <p>Their use from other packages is very simple. The
4941: <code class="varname">USE_DIRS</code> variable takes a list of package names
4942: (without the “<span class="quote">-dirs</span>” part) together with the required
4943: version number (always pick the latest one when writing new
4944: packages).</p>
4945: <p>For example, if a package installs files under
4946: <code class="filename">share/applications</code>, it should have the
4947: following line in it:</p>
4948: <pre class="programlisting">
4949: USE_DIRS+= xdg-1.1
4950: </pre>
4951: <p>After regenerating the PLIST using <span><strong class="command">make
4952: print-PLIST</strong></span>, you should get the right (commented out)
4953: lines.</p>
4954: <p>Note that even if your package is using
4955: <code class="filename">$X11BASE</code>, it must not depend on the
4956: *-x11-dirs packages. Just specify the name without that part and
4957: pkgsrc (in particular, <code class="filename">mk/dirs.mk</code>) will take
4958: care of it.</p>
1.75 rillig 4959: </div>
4960: </div>
4961: <div class="chapter" lang="en">
4962: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 4963: <a name="buildlink"></a>Chapter 13. Buildlink methodology</h2></div></div></div>
1.75 rillig 4964: <div class="toc">
4965: <p><b>Table of Contents</b></p>
4966: <dl>
1.90 ! rillig 4967: <dt><span class="sect1"><a href="#converting-to-buildlink3">13.1. Converting packages to use buildlink3</a></span></dt>
! 4968: <dt><span class="sect1"><a href="#creating-buildlink3.mk">13.2. Writing <code class="filename">buildlink3.mk</code> files</a></span></dt>
1.75 rillig 4969: <dd><dl>
1.90 ! rillig 4970: <dt><span class="sect2"><a href="#anatomy-of-bl3">13.2.1. Anatomy of a buildlink3.mk file</a></span></dt>
! 4971: <dt><span class="sect2"><a href="#updating-buildlink-depends">13.2.2. Updating <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code> in <code class="filename">buildlink3.mk</code> files</a></span></dt>
1.75 rillig 4972: </dl></dd>
1.90 ! rillig 4973: <dt><span class="sect1"><a href="#writing-builtin.mk">13.3. Writing <code class="filename">builtin.mk</code> files</a></span></dt>
1.75 rillig 4974: <dd><dl>
1.90 ! rillig 4975: <dt><span class="sect2"><a href="#anatomy-of-builtin.mk">13.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</a></span></dt>
! 4976: <dt><span class="sect2"><a href="#native-or-pkgsrc-preference">13.3.2. Global preferences for native or pkgsrc software</a></span></dt>
1.75 rillig 4977: </dl></dd>
4978: </dl>
4979: </div>
4980: <p>Buildlink is a framework in pkgsrc that controls what headers and libraries
1.87 wiz 4981: are seen by a package's configure and build processes. This is implemented
4982: in a two step process:</p>
1.75 rillig 4983: <div class="orderedlist"><ol type="1">
4984: <li><p>Symlink headers and libraries for dependencies into
1.87 wiz 4985: <code class="varname">BUILDLINK_DIR</code>, which by default is a subdirectory
4986: of <code class="varname">WRKDIR</code>.</p></li>
1.75 rillig 4987: <li><p>Create wrapper scripts that are used in place of the normal compiler
1.87 wiz 4988: tools that translate <code class="option">-I${LOCALBASE}/include</code> and
4989: <code class="option">-L${LOCALBASE}/lib</code> into references to
4990: <code class="varname">BUILDLINK_DIR</code>. The wrapper scripts also make
4991: native compiler on some operating systems look like GCC, so that
4992: packages that expect GCC won't require modifications to build with
4993: those native compilers.</p></li>
1.75 rillig 4994: </ol></div>
4995: <p>This normalizes the environment in which a package is built so that the
1.87 wiz 4996: package may be built consistently despite what other software may be
4997: installed. Please note that the normal system header and library paths,
4998: e.g. <code class="filename">/usr/include</code>,
4999: <code class="filename">/usr/lib</code>, etc., are always searched -- buildlink3 is
5000: designed to insulate the package build from non-system-supplied
5001: software.</p>
1.75 rillig 5002: <div class="sect1" lang="en">
5003: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 5004: <a name="converting-to-buildlink3"></a>13.1. Converting packages to use buildlink3</h2></div></div></div>
1.75 rillig 5005: <p>The process of converting packages to use the buildlink3
1.87 wiz 5006: framework (“<span class="quote">bl3ifying</span>”) is fairly straightforward.
5007: The things to keep in mind are:</p>
1.75 rillig 5008: <div class="orderedlist"><ol type="1">
1.87 wiz 5009: <li><p>Ensure that the build always calls the wrapper scripts
5010: instead of the actual toolchain. Some packages are tricky,
5011: and the only way to know for sure is the check
5012: <code class="filename">${WRKDIR}/.work.log</code> to see if the
5013: wrappers are being invoked.</p></li>
5014: <li><p>Don't override <code class="varname">PREFIX</code> from within
5015: the package Makefile, e.g. Java VMs, standalone shells,
5016: etc., because the code to symlink files into
5017: <code class="filename">${BUILDLINK_DIR}</code> looks for files
5018: relative to “<span class="quote">pkg_info -qp <em class="replaceable"><code>pkgname</code></em></span>”.
5019: </p></li>
5020: <li><p>Remember that <span class="emphasis"><em>only</em></span> the
5021: <code class="filename">buildlink3.mk</code> files that you list in a
5022: package's Makefile are added as dependencies for that package.
5023: </p></li>
1.75 rillig 5024: </ol></div>
1.87 wiz 5025: <p>If a dependency on a particular package is required for its libraries and
5026: headers, then we replace:</p>
1.75 rillig 5027: <pre class="programlisting">
1.87 wiz 5028: DEPENDS+= foo>=1.1.0:../../category/foo
5029: </pre>
1.75 rillig 5030: <p>with</p>
5031: <pre class="programlisting">
1.87 wiz 5032: .include "../../category/foo/buildlink3.mk"
5033: </pre>
1.75 rillig 5034: <p>The buildlink3.mk files usually define the required dependencies.
5035: If you need a newer version of the dependency when using buildlink3.mk
1.87 wiz 5036: files, then you can define it in your Makefile; for example:</p>
1.75 rillig 5037: <pre class="programlisting">
1.87 wiz 5038: BUILDLINK_API_DEPENDS.foo+= foo>=1.1.0
5039: .include "../../category/foo/buildlink3.mk"
5040: </pre>
1.76 rillig 5041: <p>There are several <code class="filename">buildlink3.mk</code>
1.87 wiz 5042: files in <code class="filename">pkgsrc/mk</code>
5043: that handle special package issues:</p>
1.75 rillig 5044: <div class="itemizedlist"><ul type="disc">
1.76 rillig 5045: <li><p><code class="filename">bdb.buildlink3.mk</code> chooses either
1.87 wiz 5046: the native or a pkgsrc Berkeley DB implementation based on
5047: the values of <code class="varname">BDB_ACCEPTED</code> and
5048: <code class="varname">BDB_DEFAULT</code>.</p></li>
1.76 rillig 5049: <li><p><code class="filename">curses.buildlink3.mk</code>: If the system
1.87 wiz 5050: comes with neither Curses nor NCurses, this will take care
5051: to install the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/ncurses/README.html" target="_top"><code class="filename">devel/ncurses</code></a> package.</p></li>
1.76 rillig 5052: <li><p><code class="filename">krb5.buildlink3.mk</code> uses the value
1.87 wiz 5053: of <code class="varname">KRB5_ACCEPTED</code> to choose between
5054: adding a dependency on Heimdal or MIT-krb5 for packages that
5055: require a Kerberos 5 implementation.</p></li>
1.88 wiz 5056: <li><p><code class="filename">motif.buildlink3.mk</code> checks for a
5057: system-provided Motif installation or adds a dependency on
5058: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/lesstif/README.html" target="_top"><code class="filename">x11/lesstif</code></a> or <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/openmotif/README.html" target="_top"><code class="filename">x11/openmotif</code></a>. The user can set
5059: <code class="varname">MOTIF_TYPE</code> to “<span class="quote">dt</span>”,
5060: “<span class="quote">lesstif</span>”, or “<span class="quote">openmotif</span>” to choose
5061: which Motif version will be used.</p></li>
1.76 rillig 5062: <li><p><code class="filename">oss.buildlink3.mk</code> defines several
1.87 wiz 5063: variables that may be used by packages that use the
5064: Open Sound System (OSS) API.</p></li>
1.76 rillig 5065: <li><p><code class="filename">pgsql.buildlink3.mk</code> will accept
1.87 wiz 5066: either Postgres 7.3 or 7.4, whichever is found installed. See
5067: the file for more information.</p></li>
1.76 rillig 5068: <li><p><code class="filename">pthread.buildlink3.mk</code> uses the value of
1.87 wiz 5069: <code class="varname">PTHREAD_OPTS</code> and checks for native pthreads or adds
5070: a dependency on <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/pth/README.html" target="_top"><code class="filename">devel/pth</code></a> as needed.</p></li>
1.76 rillig 5071: <li><p><code class="filename">xaw.buildlink3.mk</code> uses the value of
1.87 wiz 5072: <code class="varname">XAW_TYPE</code> to choose a particular Athena widgets
5073: library.</p></li>
1.75 rillig 5074: </ul></div>
1.76 rillig 5075: <p>The comments in those <code class="filename">buildlink3.mk</code>
1.87 wiz 5076: files provide a more complete
5077: description of how to use them properly.</p>
1.75 rillig 5078: </div>
5079: <div class="sect1" lang="en">
5080: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 5081: <a name="creating-buildlink3.mk"></a>13.2. Writing <code class="filename">buildlink3.mk</code> files</h2></div></div></div>
1.87 wiz 5082: <p>A package's <code class="filename">buildlink3.mk</code> file is
5083: included by Makefiles to indicate the need to compile and link
5084: against header files and libraries provided by the package. A
5085: <code class="filename">buildlink3.mk</code> file should always provide
5086: enough information to add the correct type of dependency
5087: relationship and include any other
5088: <code class="filename">buildlink3.mk</code> files that it needs to find
5089: headers and libraries that it needs in turn.</p>
5090: <p>To generate an initial <code class="filename">buildlink3.mk</code>
5091: file for further editing, Rene Hexel's <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/createbuildlink/README.html" target="_top"><code class="filename">pkgtools/createbuildlink</code></a>
5092: package is highly recommended. For most packages, the following
5093: command will generate a good starting point for
5094: <code class="filename">buildlink3.mk</code> files:</p>
5095: <pre class="screen">
5096: <code class="prompt">%</code> <strong class="userinput"><code>cd pkgsrc/<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>pkgdir</code></em>
5097: <code class="prompt">%</code> createbuildlink >buildlink3.mk</code></strong>
5098: </pre>
1.75 rillig 5099: <div class="sect2" lang="en">
5100: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 5101: <a name="anatomy-of-bl3"></a>13.2.1. Anatomy of a buildlink3.mk file</h3></div></div></div>
1.75 rillig 5102: <p>The following real-life example
1.87 wiz 5103: <code class="filename">buildlink3.mk</code> is taken
5104: from <code class="filename">pkgsrc/graphics/tiff</code>:</p>
1.75 rillig 5105: <pre class="programlisting">
1.87 wiz 5106: # $NetBSD: buildlink3.mk,v 1.7 2004/03/18 09:12:12 jlam Exp $
1.1 grant 5107:
1.87 wiz 5108: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
5109: TIFF_BUILDLINK3_MK:= ${TIFF_BUILDLINK3_MK}+
1.1 grant 5110:
1.87 wiz 5111: .if !empty(BUILDLINK_DEPTH:M+)
5112: BUILDLINK_DEPENDS+= tiff
5113: .endif
5114:
5115: BUILDLINK_PACKAGES:= ${BUILDLINK_PACKAGES:Ntiff}
5116: BUILDLINK_PACKAGES+= tiff
5117:
5118: .if !empty(TIFF_BUILDLINK3_MK:M+)
5119: BUILDLINK_API_DEPENDS.tiff+= tiff>=3.6.1
5120: BUILDLINK_PKGSRCDIR.tiff?= ../../graphics/tiff
5121: .endif # TIFF_BUILDLINK3_MK
5122:
5123: .include "../../devel/zlib/buildlink3.mk"
5124: .include "../../graphics/jpeg/buildlink3.mk"
5125:
5126: BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH:S/+$//}
5127: </pre>
5128: <p>The header and footer manipulate
5129: <code class="varname">BUILDLINK_DEPTH</code>, which is common across all
5130: <code class="filename">buildlink3.mk</code> files and is used to track
5131: at what depth we are including
5132: <code class="filename">buildlink3.mk</code> files.</p>
5133: <p>The first section controls if the dependency on
5134: <em class="replaceable"><code>pkg</code></em> is added.
5135: <code class="varname">BUILDLINK_DEPENDS</code> is the global list of
5136: packages for which dependencies are added by
5137: buildlink3.</p>
5138: <p>The second section advises pkgsrc that the
5139: <code class="filename">buildlink3.mk</code> file for
5140: <em class="replaceable"><code>pkg</code></em> has been included at some point.
5141: <code class="varname">BUILDLINK_PACKAGES</code> is the global list of
5142: packages for which <code class="filename">buildlink3.mk</code> files
5143: have been included. It must <span class="emphasis"><em>always</em></span> be
5144: appended to within a <code class="filename">buildlink3.mk</code>
5145: file.</p>
5146: <p>The third section is protected from multiple inclusion
5147: and controls how the dependency on <em class="replaceable"><code>pkg</code></em> is
5148: added. Several important variables are set in the section:</p>
5149: <div class="itemizedlist"><ul type="disc">
5150: <li><p><code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5151: is the actual dependency recorded in the installed
5152: package; this should always be set using
5153: <span><strong class="command">+=</strong></span> to ensure that
5154: we're appending to any pre-existing list of values. This
5155: variable should be set to the first version of the
5156: package that had an API change.
5157: </p></li>
5158: <li><p><code class="varname">BUILDLINK_PKGSRCDIR.<em class="replaceable"><code>pkg</code></em></code>
5159: is the location of the <em class="replaceable"><code>pkg</code></em>
5160: pkgsrc directory.</p></li>
5161: <li><p><code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
5162: (not shown above) controls whether we use
5163: <code class="varname">BUILD_DEPENDS</code> or
5164: <code class="varname">DEPENDS</code> to add the dependency on
5165: <em class="replaceable"><code>pkg</code></em>. The build dependency is
5166: selected by setting
5167: <code class="varname">BUILDLINK_DEPMETHOD.<em class="replaceable"><code>pkg</code></em></code>
5168: to “<span class="quote">build</span>”. By default, the full dependency is
5169: used.</p></li>
5170: <li><p><code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5171: and
5172: <code class="varname">BUILDLINK_LIBDIRS.<em class="replaceable"><code>pkg</code></em></code>
5173: (not shown above) are lists of subdirectories of
1.76 rillig 5174: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 5175: to add to the header and library search paths. These
5176: default to “<span class="quote">include</span>” and “<span class="quote">lib</span>”
1.87 wiz 5177: respectively.</p></li>
5178: <li><p><code class="varname">BUILDLINK_CPPFLAGS.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5179: (not shown above) is the list of preprocessor flags to add
5180: to <code class="varname">CPPFLAGS</code>, which are passed on to the
5181: configure and build phases. The “<span class="quote">-I</span>” option
5182: should be avoided and instead be handled using
5183: <code class="varname">BUILDLINK_INCDIRS.<em class="replaceable"><code>pkg</code></em></code> as
1.87 wiz 5184: above.</p></li>
1.75 rillig 5185: </ul></div>
1.87 wiz 5186: <p>The following variables are all optionally defined within
5187: this second section (protected against multiple inclusion) and
5188: control which package files are symlinked into
5189: <code class="filename">${BUILDLINK_DIR}</code> and how their names are
5190: transformed during the symlinking:</p>
1.75 rillig 5191: <div class="itemizedlist"><ul type="disc">
1.87 wiz 5192: <li><p><code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5193: (not shown above) is a shell glob pattern relative to
1.76 rillig 5194: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 5195: to be symlinked into
1.76 rillig 5196: <code class="filename">${BUILDLINK_DIR}</code>,
1.87 wiz 5197: e.g. <code class="filename">include/*.h</code>.</p></li>
5198: <li><p><code class="varname">BUILDLINK_FILES_CMD.<em class="replaceable"><code>pkg</code></em></code>
5199: (not shown above) is a shell pipeline that
5200: outputs to stdout a list of files relative to
5201: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>.
5202: The resulting files are to be symlinked
5203: into <code class="filename">${BUILDLINK_DIR}</code>. By default,
5204: this takes the <code class="filename">+CONTENTS</code> of a
5205: <em class="replaceable"><code>pkg</code></em> and filters it through
5206: <code class="varname">${BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em>}</code>.</p></li>
5207: <li><p><code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5208: (not shown above) is a filter command that filters
1.76 rillig 5209: <code class="filename">+CONTENTS</code> input into a list of files
1.75 rillig 5210: relative to
1.76 rillig 5211: <code class="filename">${BUILDLINK_PREFIX.<em class="replaceable"><code>pkg</code></em>}</code>
1.75 rillig 5212: on stdout. By default for overwrite packages,
5213: <code class="varname">BUILDLINK_CONTENTS_FILTER.<em class="replaceable"><code>pkg</code></em></code>
1.76 rillig 5214: outputs the contents of the <code class="filename">include</code>
5215: and <code class="filename">lib</code> directories in the package
5216: <code class="filename">+CONTENTS</code>, and for pkgviews packages,
1.75 rillig 5217: it outputs any libtool archives in
1.87 wiz 5218: <code class="filename">lib</code> directories.</p></li>
5219: <li><p><code class="varname">BUILDLINK_TRANSFORM.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5220: (not shown above) is a list of sed arguments used to
5221: transform the name of the source filename into a
5222: destination filename, e.g. <span><strong class="command">-e
1.87 wiz 5223: "s|/curses.h|/ncurses.h|g"</strong></span>.</p></li>
1.75 rillig 5224: </ul></div>
1.87 wiz 5225: <p>The last section includes any
5226: <code class="filename">buildlink3.mk</code> needed for
5227: <em class="replaceable"><code>pkg</code></em>'s library dependencies.
5228: Including these <code class="filename">buildlink3.mk</code> files
5229: means that the headers and libraries for these
5230: dependencies are also symlinked into
5231: <code class="filename">${BUILDLINK_DIR}</code>
5232: whenever the <em class="replaceable"><code>pkg</code></em>
5233: <code class="filename">buildlink3.mk</code>
5234: file is included.</p>
1.75 rillig 5235: </div>
5236: <div class="sect2" lang="en">
5237: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 5238: <a name="updating-buildlink-depends"></a>13.2.2. Updating <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code> in <code class="filename">buildlink3.mk</code> files</h3></div></div></div>
1.87 wiz 5239: <p>The situation that requires increasing the dependency listed in
1.75 rillig 5240: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5241: after a package update is when the API or interface to the
1.87 wiz 5242: header files change.</p>
5243: <p>In this case,
5244: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5245: should be adjusted to require at least the new package
5246: version. In some cases, the packages that depend on this new
5247: version may need their <code class="varname">PKGREVISION</code>s
5248: increased and, if they have <code class="filename">buildlink3.mk</code>
5249: files, their
5250: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5251: adjusted, too. This is needed so pkgsrc will require the
5252: correct package dependency and not settle for an older one
5253: when building the source.</p>
5254: <p><code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
1.75 rillig 5255: should be increased when the binary interface or sonames
5256: (major number of the library version) of any installed
5257: shared libraries change. This is needed so that binary
5258: packages made using it will require the correct package
5259: dependency and not settle for an older one which will not
1.87 wiz 5260: contain the necessary shared libraries.</p>
1.90 ! rillig 5261: <p>See <a href="#dependencies" title="18.1.6. Handling dependencies">Section 18.1.6, “Handling dependencies”</a> for
1.75 rillig 5262: more information about dependencies on other packages,
5263: including the <code class="varname">BUILDLINK_ABI_DEPENDS</code> and
1.87 wiz 5264: <code class="varname">ABI_DEPENDS</code> definitions.</p>
5265: <p>Please take careful consideration before adjusting
5266: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5267: or
5268: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5269: as we don't want to cause unneeded package deletions and
5270: rebuilds. In many cases, new versions of packages work just
5271: fine with older dependencies.</p>
5272: <p>Also it is not needed to set
1.75 rillig 5273: <code class="varname">BUILDLINK_ABI_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>
5274: when it is identical to
1.87 wiz 5275: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>. </p>
1.75 rillig 5276: </div>
5277: </div>
5278: <div class="sect1" lang="en">
5279: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 5280: <a name="writing-builtin.mk"></a>13.3. Writing <code class="filename">builtin.mk</code> files</h2></div></div></div>
1.87 wiz 5281: <p>Some packages in pkgsrc install headers and libraries that
1.75 rillig 5282: coincide with headers and libraries present in the base system.
1.76 rillig 5283: Aside from a <code class="filename">buildlink3.mk</code> file, these
5284: packages should also include a <code class="filename">builtin.mk</code>
1.75 rillig 5285: file that includes the necessary checks to decide whether using
5286: the built-in software or the pkgsrc software is
1.87 wiz 5287: appropriate.</p>
5288: <p>The only requirements of a builtin.mk file for
5289: <em class="replaceable"><code>pkg</code></em> are:</p>
1.75 rillig 5290: <div class="orderedlist"><ol type="1">
1.87 wiz 5291: <li><p>It should set
5292: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5293: to either “<span class="quote">yes</span>” or “<span class="quote">no</span>”
5294: after it is included.</p></li>
5295: <li><p>It should <span class="emphasis"><em>not</em></span> override any
5296: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5297: which is already set before the
5298: <code class="filename">builtin.mk</code> file is included.</p></li>
5299: <li><p>It should be written to allow multiple inclusion. This
5300: is <span class="emphasis"><em>very</em></span> important and takes careful
5301: attention to <code class="filename">Makefile</code> coding.</p></li>
1.75 rillig 5302: </ol></div>
5303: <div class="sect2" lang="en">
5304: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 5305: <a name="anatomy-of-builtin.mk"></a>13.3.1. Anatomy of a <code class="filename">builtin.mk</code> file</h3></div></div></div>
1.75 rillig 5306: <p>The following is the recommended template for builtin.mk
1.87 wiz 5307: files:</p>
1.75 rillig 5308: <pre class="programlisting">
1.87 wiz 5309: .if !defined(IS_BUILTIN.foo)
5310: #
5311: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
5312: # genuinely exists in the system or not.
5313: #
5314: IS_BUILTIN.foo?= no
5315:
5316: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
5317: # version can be determined.
5318: #
5319: . if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
5320: BUILTIN_PKG.foo?= foo-1.0
5321: . endif
5322: .endif # IS_BUILTIN.foo
5323:
5324: .if !defined(USE_BUILTIN.foo)
5325: USE_BUILTIN.foo?= ${IS_BUILTIN.foo}
5326: . if defined(BUILTIN_PKG.foo)
5327: . for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
5328: . if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
5329: USE_BUILTIN.foo!= \
5330: if ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}; then \
5331: ${ECHO} "yes"; \
5332: else \
5333: ${ECHO} "no"; \
5334: fi
5335: . endif
5336: . endfor
5337: . endif
5338: .endif # USE_BUILTIN.foo
5339:
5340: CHECK_BUILTIN.foo?= no
5341: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
5342: #
5343: # Here we place code that depends on whether USE_BUILTIN.foo is set to
5344: # "yes" or "no".
5345: #
5346: .endif # CHECK_BUILTIN.foo
5347: </pre>
5348: <p>The first section sets
5349: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5350: depending on if <em class="replaceable"><code>pkg</code></em> really exists
5351: in the base system. This should not be a base system software
5352: with similar functionality to <em class="replaceable"><code>pkg</code></em>;
5353: it should only be “<span class="quote">yes</span>” if the actual package is
5354: included as part of the base system. This variable is only
5355: used internally within the <code class="filename">builtin.mk</code>
5356: file.</p>
5357: <p>The second section sets
5358: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
5359: to the version of <em class="replaceable"><code>pkg</code></em> in the base
5360: system if it exists (if
5361: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5362: is “<span class="quote">yes</span>”). This variable is only used internally
5363: within the <code class="filename">builtin.mk</code> file.</p>
5364: <p>The third section sets
5365: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5366: and is <span class="emphasis"><em>required</em></span> in all
5367: <code class="filename">builtin.mk</code> files. The code in this
5368: section must make the determination whether the built-in
5369: software is adequate to satisfy the dependencies listed in
5370: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
5371: This is typically done by comparing
5372: <code class="varname">BUILTIN_PKG.<em class="replaceable"><code>pkg</code></em></code>
5373: against each of the dependencies in
5374: <code class="varname">BUILDLINK_API_DEPENDS.<em class="replaceable"><code>pkg</code></em></code>.
5375: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5376: <span class="emphasis"><em>must</em></span> be set to the correct value by the
5377: end of the <code class="filename">builtin.mk</code> file. Note that
5378: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5379: may be “<span class="quote">yes</span>” even if
5380: <code class="varname">IS_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5381: is “<span class="quote">no</span>” because we may make the determination
5382: that the built-in version of the software is similar enough to
5383: be used as a replacement.</p>
5384: <p>The last section is guarded by
5385: <code class="varname">CHECK_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>,
5386: and includes code that uses the value of
5387: <code class="varname">USE_BUILTIN.<em class="replaceable"><code>pkg</code></em></code>
5388: set in the previous section. This typically includes, e.g.,
5389: adding additional dependency restrictions and listing additional
5390: files to symlink into <code class="filename">${BUILDLINK_DIR}</code> (via
5391: <code class="varname">BUILDLINK_FILES.<em class="replaceable"><code>pkg</code></em></code>).</p>
1.75 rillig 5392: </div>
5393: <div class="sect2" lang="en">
5394: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 5395: <a name="native-or-pkgsrc-preference"></a>13.3.2. Global preferences for native or pkgsrc software</h3></div></div></div>
1.87 wiz 5396: <p>When building packages, it's possible to choose whether to set
5397: a global preference for using either the built-in (native)
5398: version or the pkgsrc version of software to satisfy a
5399: dependency. This is controlled by setting
5400: <code class="varname">PREFER_PKGSRC</code> and
5401: <code class="varname">PREFER_NATIVE</code>. These variables take values
5402: of either “<span class="quote">yes</span>”, “<span class="quote">no</span>”, or a list of
5403: packages. <code class="varname">PREFER_PKGSRC</code> tells pkgsrc to
5404: use the pkgsrc versions of software, while
5405: <code class="varname">PREFER_NATIVE</code> tells pkgsrc to use the
5406: built-in versions. Preferences are determined by the most
5407: specific instance of the package in either
5408: <code class="varname">PREFER_PKGSRC</code> or
5409: <code class="varname">PREFER_NATIVE</code>. If a package is specified
5410: in neither or in both variables, then
5411: <code class="varname">PREFER_PKGSRC</code> has precedence over
5412: <code class="varname">PREFER_NATIVE</code>. For example, to require
5413: using pkgsrc versions of software for all but the most basic
5414: bits on a NetBSD system, you can set:</p>
5415: <pre class="programlisting">
5416: PREFER_PKGSRC= yes
5417: PREFER_NATIVE= getopt skey tcp_wrappers
5418: </pre>
5419: <p>A package <span class="emphasis"><em>must</em></span> have a
5420: <code class="filename">builtin.mk</code>
5421: file to be listed in <code class="varname">PREFER_NATIVE</code>,
5422: otherwise it is simply ignored in that list.</p>
1.75 rillig 5423: </div>
5424: </div>
5425: </div>
5426: <div class="chapter" lang="en">
5427: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 5428: <a name="pkginstall"></a>Chapter 14. The pkginstall framework</h2></div></div></div>
1.75 rillig 5429: <div class="toc">
5430: <p><b>Table of Contents</b></p>
5431: <dl>
1.90 ! rillig 5432: <dt><span class="sect1"><a href="#files-and-dirs-outside-prefix">14.1. Files and directories outside the installation prefix</a></span></dt>
1.75 rillig 5433: <dd><dl>
1.90 ! rillig 5434: <dt><span class="sect2"><a href="#dirs-outside-prefix">14.1.1. Directory manipulation</a></span></dt>
! 5435: <dt><span class="sect2"><a href="#files-outside-prefix">14.1.2. File manipulation</a></span></dt>
1.75 rillig 5436: </dl></dd>
1.90 ! rillig 5437: <dt><span class="sect1"><a href="#conf-files">14.2. Configuration files</a></span></dt>
1.75 rillig 5438: <dd><dl>
1.90 ! rillig 5439: <dt><span class="sect2"><a href="#conf-files-sysconfdir">14.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</a></span></dt>
! 5440: <dt><span class="sect2"><a href="#conf-files-configure">14.2.2. Telling the software where configuration files are</a></span></dt>
! 5441: <dt><span class="sect2"><a href="#conf-files-patching">14.2.3. Patching installations</a></span></dt>
! 5442: <dt><span class="sect2"><a href="#conf-files-disable">14.2.4. Disabling handling of configuration files</a></span></dt>
! 5443: </dl></dd>
! 5444: <dt><span class="sect1"><a href="#rcd-scripts">14.3. System startup scripts</a></span></dt>
! 5445: <dd><dl><dt><span class="sect2"><a href="#rcd-scripts-disable">14.3.1. Disabling handling of system startup scripts</a></span></dt></dl></dd>
! 5446: <dt><span class="sect1"><a href="#users-and-groups">14.4. System users and groups</a></span></dt>
! 5447: <dt><span class="sect1"><a href="#shells">14.5. System shells</a></span></dt>
! 5448: <dd><dl><dt><span class="sect2"><a href="#shells-disable">14.5.1. Disabling shell registration</a></span></dt></dl></dd>
! 5449: <dt><span class="sect1"><a href="#fonts">14.6. Fonts</a></span></dt>
! 5450: <dd><dl><dt><span class="sect2"><a href="#fonts-disable">14.6.1. Disabling automatic update of the fonts databases</a></span></dt></dl></dd>
1.75 rillig 5451: </dl>
5452: </div>
5453: <p>This chapter describes the framework known as
5454: <code class="literal">pkginstall</code>, whose key features are:</p>
5455: <div class="itemizedlist"><ul type="disc">
5456: <li><p>Generic installation and manipulation of directories and files
5457: outside the pkgsrc-handled tree, <code class="varname">LOCALBASE</code>.</p></li>
5458: <li><p>Automatic handling of configuration files during installation,
5459: provided that packages are correctly designed.</p></li>
5460: <li><p>Generation and installation of system startup scripts.</p></li>
5461: <li><p>Registration of system users and groups.</p></li>
5462: <li><p>Registration of system shells.</p></li>
5463: <li><p>Automatic updating of fonts databases.</p></li>
5464: </ul></div>
5465: <p>The following sections inspect each of the above points in detail.</p>
5466: <p>You may be thinking that many of the things described here could be
5467: easily done with simple code in the package's post-installation target
5468: (<code class="literal">post-install</code>). <span class="emphasis"><em>This is incorrect</em></span>,
5469: as the code in them is only executed when building from source. Machines
5470: using binary packages could not benefit from it at all (as the code itself
5471: could be unavailable). Therefore, the only way to achieve any of the items
5472: described above is by means of the installation scripts, which are
5473: automatically generated by pkginstall.</p>
5474: <div class="sect1" lang="en">
5475: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 5476: <a name="files-and-dirs-outside-prefix"></a>14.1. Files and directories outside the installation prefix</h2></div></div></div>
1.76 rillig 5477: <p>As you already know, the <code class="filename">PLIST</code> file holds a list
1.75 rillig 5478: of files and directories that belong to a package. The names used in it
1.76 rillig 5479: are relative to the installation prefix (<code class="filename">${PREFIX}</code>),
1.75 rillig 5480: which means that it cannot register files outside this directory (absolute
5481: path names are not allowed). Despite this restriction, some packages need
5482: to install files outside this location; e.g., under
1.76 rillig 5483: <code class="filename">${VARBASE}</code> or
1.87 wiz 5484: <code class="filename">${PKG_SYSCONFDIR}</code>. The only way to achieve this
5485: is to create such files during installation time by using
5486: installation scripts.</p>
5487: <p>The generic installation scripts are shell scripts that can
5488: contain arbitrary code. The list of scripts to execute is taken from
5489: the <code class="varname">INSTALL_FILE</code> variable, which defaults to
5490: <code class="filename">INSTALL</code>. A similar variable exists for package
5491: removal (<code class="varname">DEINSTALL_FILE</code>, whose default is
5492: <code class="filename">DEINSTALL</code>). These scripts can run arbitrary
5493: commands, so they have the potential to create and manage files
5494: anywhere in the file system.</p>
5495: <p>Using these general installation files is not recommended, but
5496: may be needed in some special cases. One reason for avoiding them is
5497: that the user has to trust the packager that there is no unwanted or
5498: simply erroneous code included in the installation script. Also,
5499: previously there were many similar scripts for the same functionality,
5500: and fixing a common error involved finding and changing all of
5501: them.</p>
5502: <p>The pkginstall framework offers another, standardized way. It
5503: provides generic scripts to abstract the manipulation of such files
5504: and directories based on variables set in the package's
5505: <code class="filename">Makefile</code>. The rest of this section describes
5506: these variables.</p>
1.75 rillig 5507: <div class="sect2" lang="en">
5508: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 5509: <a name="dirs-outside-prefix"></a>14.1.1. Directory manipulation</h3></div></div></div>
1.75 rillig 5510: <p>The following variables can be set to request the creation of
5511: directories anywhere in the file system:</p>
5512: <div class="itemizedlist"><ul type="disc">
5513: <li><p><code class="varname">MAKE_DIRS</code> and <code class="varname">OWN_DIRS</code>
5514: contain a list of directories that should be created and should attempt
5515: to be destroyed by the installation scripts. The difference between
5516: the two is that the latter prompts the administrator to remove any
5517: directories that may be left after deinstallation (because they were
5518: not empty), while the former does not.</p></li>
5519: <li>
5520: <p><code class="varname">MAKE_DIRS_PERMS</code> and
5521: <code class="varname">OWN_DIRS_PERMS</code> contain a list of tuples describing
5522: which directories should be created and should attempt to be destroyed
5523: by the installation scripts. Each tuple holds the following values,
5524: separated by spaces: the directory name, its owner, its group and its
5525: numerical mode. For example:</p>
5526: <pre class="programlisting">
5527: MAKE_DIRS_PERMS+= ${VARBASE}/foo/private ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 5528: </pre>
1.75 rillig 5529: <p>The difference between the two is exactly the same as their
5530: non-<code class="varname">PERMS</code> counterparts.</p>
5531: </li>
5532: </ul></div>
5533: </div>
5534: <div class="sect2" lang="en">
5535: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 5536: <a name="files-outside-prefix"></a>14.1.2. File manipulation</h3></div></div></div>
1.75 rillig 5537: <p>Creating non-empty files outside the installation prefix is tricky
1.76 rillig 5538: because the <code class="filename">PLIST</code> forces all files to be inside it.
1.75 rillig 5539: To overcome this problem, the only solution is to extract the file in the
5540: known place (i.e., inside the installation prefix) and copy it to the
5541: appropriate location during installation (done by the installation scripts
5542: generated by pkginstall). We will call the former the <span class="emphasis"><em>master
5543: file</em></span> in the following paragraphs, which describe the variables
5544: that can be used to automatically and consistently handle files outside the
5545: installation prefix:</p>
5546: <div class="itemizedlist"><ul type="disc">
5547: <li>
5548: <p><code class="varname">CONF_FILES</code> and
5549: <code class="varname">SUPPORT_FILES</code> are pairs of master and target files.
5550: During installation time, the master file is copied to the target one
5551: if and only if the latter does not exist. Upon deinstallation, the
5552: target file is removed provided that it was not modified by the
5553: installation.</p>
5554: <p>The difference between the two is that the latter prompts the
5555: administrator to remove any files that may be left after
5556: deinstallation (because they were not empty), while the former does
5557: not.</p>
5558: </li>
5559: <li>
5560: <p><code class="varname">CONF_FILES_PERMS</code> and
5561: <code class="varname">SUPPORT_FILES_PERMS</code> contain tuples describing master
5562: files as well as their target locations. For each of them, it also
5563: specifies their owner, their group and their numeric permissions, in
5564: this order. For example:</p>
5565: <pre class="programlisting">
5566: SUPPORT_FILES_PERMS+= ${PREFIX}/share/somefile ${VARBASE}/somefile ${ROOT_USER} ${ROOT_GROUP} 0700
1.1 grant 5567: </pre>
1.75 rillig 5568: <p>The difference between the two is exactly the same as their
5569: non-<code class="varname">PERMS</code> counterparts.</p>
5570: </li>
5571: </ul></div>
5572: </div>
5573: </div>
5574: <div class="sect1" lang="en">
5575: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 5576: <a name="conf-files"></a>14.2. Configuration files</h2></div></div></div>
1.75 rillig 5577: <p>Configuration files are special in the sense that they are installed
5578: in their own specific directory, <code class="varname">PKG_SYSCONFDIR</code>, and
5579: need special treatment during installation (most of which is automated by
5580: pkginstall). The main concept you must bear in mind is that files marked
5581: as configuration files are automatically copied to the right place (somewhere
5582: inside <code class="varname">PKG_SYSCONFDIR</code>) during installation <span class="emphasis"><em>if
5583: and only if</em></span> they didn't exist before. Similarly, they will not
5584: be removed if they have local modifications. This ensures that
5585: administrators never lose any custom changes they may have made.</p>
5586: <div class="sect2" lang="en">
5587: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 5588: <a name="conf-files-sysconfdir"></a>14.2.1. How <code class="varname">PKG_SYSCONFDIR</code> is set</h3></div></div></div>
1.75 rillig 5589: <p>As said before, the <code class="varname">PKG_SYSCONFDIR</code> variable
5590: specifies where configuration files shall be installed. Its contents are
5591: set based upon the following variables:</p>
5592: <div class="itemizedlist"><ul type="disc">
5593: <li><p><code class="varname">PKG_SYSCONFBASE</code>: The configuration's root
1.76 rillig 5594: directory. Defaults to <code class="filename">${PREFIX}/etc</code> although it may
1.75 rillig 5595: be overridden by the user to point to his preferred location (e.g.,
1.76 rillig 5596: <code class="filename">/etc</code>, <code class="filename">/etc/pkg</code>, etc.).
1.75 rillig 5597: Packages must not use it directly.</p></li>
5598: <li>
5599: <p><code class="varname">PKG_SYSCONFSUBDIR</code>: A subdirectory of
5600: <code class="varname">PKG_SYSCONFBASE</code> under which the configuration files
5601: for the package being built shall be installed. The definition of this
5602: variable only makes sense in the package's
1.76 rillig 5603: <code class="filename">Makefile</code> (i.e., it is not user-customizable).</p>
1.75 rillig 5604: <p>As an example, consider the Apache package,
1.76 rillig 5605: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/apache2/README.html" target="_top"><code class="filename">www/apache2</code></a>, which places its
1.75 rillig 5606: configuration files under the
1.76 rillig 5607: <code class="filename">httpd/</code> subdirectory of
1.75 rillig 5608: <code class="varname">PKG_SYSCONFBASE</code>. This should be set in the package
5609: Makefile.</p>
5610: </li>
5611: <li><p><code class="varname">PKG_SYSCONFVAR</code>: Specifies the name of the
5612: variable that holds this package's configuration directory (if
5613: different from <code class="varname">PKG_SYSCONFBASE</code>). It defaults to
5614: <code class="varname">PKGBASE</code>'s value, and is always prefixed with
5615: <code class="literal">PKG_SYSCONFDIR</code>.</p></li>
5616: <li><p><code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code>: Holds the
5617: directory where the configuration files for the package identified by
5618: <code class="varname">PKG_SYSCONFVAR</code>'s shall be placed.</p></li>
5619: </ul></div>
5620: <p>Based on the above variables, pkginstall determines the value of
5621: <code class="varname">PKG_SYSCONFDIR</code>, which is the <span class="emphasis"><em>only</em></span>
5622: variable that can be used within a package to refer to its configuration
5623: directory. The algorithm used to set its value is basically the
5624: following:</p>
5625: <div class="orderedlist"><ol type="1">
5626: <li><p>If <code class="varname">PKG_SYSCONFDIR.${PKG_SYSCONFVAR}</code> is set,
5627: its value is used.</p></li>
5628: <li><p>If the previous variable is not defined but
5629: <code class="varname">PKG_SYSCONFSUBDIR</code> is set in the package's
1.76 rillig 5630: <code class="filename">Makefile</code>, the resulting value is
5631: <code class="filename">${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}</code>.</p></li>
1.75 rillig 5632: <li><p>Otherwise, it is set to
1.76 rillig 5633: <code class="filename">${PKG_SYSCONFBASE}</code>.</p></li>
1.75 rillig 5634: </ol></div>
1.76 rillig 5635: <p>It is worth mentioning that <code class="filename">${PKG_SYSCONFDIR}</code> is
1.90 ! rillig 5636: automatically added to <code class="filename">OWN_DIRS</code>. See <a href="#dirs-outside-prefix" title="14.1.1. Directory manipulation">Section 14.1.1, “Directory manipulation”</a> what this means.</p>
1.75 rillig 5637: </div>
5638: <div class="sect2" lang="en">
5639: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 5640: <a name="conf-files-configure"></a>14.2.2. Telling the software where configuration files are</h3></div></div></div>
1.75 rillig 5641: <p>Given that pkgsrc (and users!) expect configuration files to be in a
5642: known place, you need to teach each package where it shall install its
5643: files. In some cases you will have to patch the package Makefiles to
5644: achieve it. If you are lucky, though, it may be as easy as passing an
5645: extra flag to the configuration script; this is the case of GNU Autoconf-
5646: generated files:</p>
5647: <pre class="programlisting">
5648: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1 grant 5649: </pre>
1.75 rillig 5650: <p>Note that this specifies where the package has to <span class="emphasis"><em>look
5651: for</em></span> its configuration files, not where they will be originally
5652: installed (although the difference is never explicit,
5653: unfortunately).</p>
5654: </div>
5655: <div class="sect2" lang="en">
5656: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 5657: <a name="conf-files-patching"></a>14.2.3. Patching installations</h3></div></div></div>
1.75 rillig 5658: <p>As said before, pkginstall automatically handles configuration files.
5659: This means that <span class="strong"><strong>the packages themselves must not
1.76 rillig 5660: touch the contents of <code class="filename">${PKG_SYSCONFDIR}</code>
1.75 rillig 5661: directly</strong></span>. Bad news is that many software installation scripts
5662: will, out of the box, mess with the contents of that directory. So what is
5663: the correct procedure to fix this issue?</p>
5664: <p>You must teach the package (usually by manually patching it) to
5665: install any configuration files under the examples hierarchy,
1.76 rillig 5666: <code class="filename">share/examples/${PKGBASE}/</code>. This way, the
5667: <code class="filename">PLIST</code> registers them and the administrator always
1.75 rillig 5668: has the original copies available.</p>
5669: <p>Once the required configuration files are in place (i.e., under the
5670: examples hierarchy), the pkginstall framework can use them as master copies
5671: during the package installation to update what is in
1.76 rillig 5672: <code class="filename">${PKG_SYSCONFDIR}</code>. To achieve this, the variables
1.75 rillig 5673: <code class="varname">CONF_FILES</code> and <code class="varname">CONF_FILES_PERMS</code> are
1.90 ! rillig 5674: used. Check out <a href="#files-outside-prefix" title="14.1.2. File manipulation">Section 14.1.2, “File manipulation”</a> for information
1.75 rillig 5675: about their syntax and their purpose. Here is an example, taken from the
1.76 rillig 5676: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/mail/mutt/README.html" target="_top"><code class="filename">mail/mutt</code></a> package:</p>
1.75 rillig 5677: <pre class="programlisting">
5678: EGDIR= ${PREFIX}/share/doc/mutt/samples
5679: CONF_FILES= ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1 grant 5680: </pre>
1.75 rillig 5681: <p>Note that the <code class="varname">EGDIR</code> variable is specific to that
5682: package and has no meaning outside it.</p>
5683: </div>
5684: <div class="sect2" lang="en">
5685: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 5686: <a name="conf-files-disable"></a>14.2.4. Disabling handling of configuration files</h3></div></div></div>
1.75 rillig 5687: <p>The automatic copying of config files can be toggled by setting the
5688: environment variable <code class="varname">PKG_CONFIG</code> prior to package
5689: installation.</p>
5690: </div>
5691: </div>
5692: <div class="sect1" lang="en">
5693: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 5694: <a name="rcd-scripts"></a>14.3. System startup scripts</h2></div></div></div>
1.75 rillig 5695: <p>System startup scripts are special files because they must be
5696: installed in a place known by the underlying OS, usually outside the
1.90 ! rillig 5697: installation prefix. Therefore, the same rules described in <a href="#files-and-dirs-outside-prefix" title="14.1. Files and directories outside the installation prefix">Section 14.1, “Files and directories outside the installation prefix”</a> apply, and the same solutions
1.75 rillig 5698: can be used. However, pkginstall provides a special mechanism to handle
5699: these files.</p>
5700: <p>In order to provide system startup scripts, the package has
5701: to:</p>
5702: <div class="orderedlist"><ol type="1">
1.76 rillig 5703: <li><p>Store the script inside <code class="filename">${FILESDIR}</code>, with
1.75 rillig 5704: the <code class="literal">.sh</code> suffix appended. Considering the
1.76 rillig 5705: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/print/cups/README.html" target="_top"><code class="filename">print/cups</code></a> package as an example, it has a
5706: <code class="filename">cupsd.sh</code> in its files directory.</p></li>
1.75 rillig 5707: <li>
5708: <p>Tell pkginstall to handle it, appending the name of the script,
5709: without its extension, to the <code class="varname">RCD_SCRIPTS</code> variable.
5710: Continuing the previous example:</p>
5711: <pre class="programlisting">
5712: RCD_SCRIPTS+= cupsd
1.1 grant 5713: </pre>
1.75 rillig 5714: </li>
5715: </ol></div>
5716: <p>Once this is done, pkginstall will do the following steps for each
5717: script in an automated fashion:</p>
5718: <div class="orderedlist"><ol type="1">
5719: <li><p>Process the file found in the files directory applying all the
1.76 rillig 5720: substitutions described in the <code class="filename">FILES_SUBST</code>
1.75 rillig 5721: variable.</p></li>
5722: <li><p>Copy the script from the files directory to the examples
1.76 rillig 5723: hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>. Note
1.75 rillig 5724: that this master file must be explicitly registered in the
1.76 rillig 5725: <code class="filename">PLIST</code>.</p></li>
1.75 rillig 5726: <li><p>Add code to the installation scripts to copy the startup script
5727: from the examples hierarchy into the system-wide startup scripts
5728: directory.</p></li>
5729: </ol></div>
5730: <div class="sect2" lang="en">
5731: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 5732: <a name="rcd-scripts-disable"></a>14.3.1. Disabling handling of system startup scripts</h3></div></div></div>
1.75 rillig 5733: <p>The automatic copying of config files can be toggled by setting the
5734: environment variable <code class="varname">PKG_RCD_SCRIPTS</code> prior to package
5735: installation. Note that the scripts will be always copied inside the
1.76 rillig 5736: examples hierarchy, <code class="filename">${PREFIX}/share/examples/rc.d/</code>, no
1.75 rillig 5737: matter what the value of this variable is.</p>
5738: </div>
5739: </div>
5740: <div class="sect1" lang="en">
5741: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 5742: <a name="users-and-groups"></a>14.4. System users and groups</h2></div></div></div>
1.75 rillig 5743: <p>If a package needs to create special users and/or groups during
5744: installation, it can do so by using the pkginstall framework.</p>
5745: <p>Users can be created by adding entries to the
5746: <code class="varname">PKG_USERS</code> variable. Each entry has the following
5747: syntax:</p>
5748: <pre class="programlisting">
5749: user:group
1.1 grant 5750: </pre>
1.87 wiz 5751: <p>Further specification of user details may be done by setting
5752: per-user variables.
5753: <code class="varname">PKG_UID.<em class="replaceable"><code>user</code></em></code> is the
5754: numeric UID for the user.
5755: <code class="varname">PKG_GECOS.<em class="replaceable"><code>user</code></em></code> is the
5756: user's description or comment.
5757: <code class="varname">PKG_HOME.<em class="replaceable"><code>user</code></em></code> is the
5758: user's home directory, and defaults to
5759: <code class="filename">/nonexistent</code> if not specified.
5760: <code class="varname">PKG_SHELL.<em class="replaceable"><code>user</code></em></code> is the
5761: user's shell, and defaults to <code class="filename">/sbinno/login</code> if
5762: not specified.</p>
1.75 rillig 5763: <p>Similarly, groups can be created by adding entries to the
5764: <code class="varname">PKG_GROUPS</code> variable, whose syntax is:</p>
5765: <pre class="programlisting">
5766: group
1.1 grant 5767: </pre>
1.75 rillig 5768: <p>The numeric GID of the group may be set by defining
5769: <code class="varname">PKG_GID.<em class="replaceable"><code>group</code></em></code>.</p>
5770: <p>If a package needs to create the users and groups at an earlier
5771: stage, then it can set <code class="varname">USERGROUP_PHASE</code> to
5772: either <code class="literal">configure</code> or <code class="literal">build</code> to
5773: indicate the phase before which the users and groups are created. In
5774: this case, the numeric UIDs and GIDs of the created users and groups
5775: are automatically hardcoded into the final installation scripts.</p>
5776: </div>
5777: <div class="sect1" lang="en">
5778: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 5779: <a name="shells"></a>14.5. System shells</h2></div></div></div>
1.75 rillig 5780: <p>Packages that install system shells should register them in the shell
1.76 rillig 5781: database, <code class="filename">/etc/shells</code>, to make things easier to the
1.75 rillig 5782: administrator. This must be done from the installation scripts to keep
5783: binary packages working on any system. pkginstall provides an easy way to
5784: accomplish this task.</p>
5785: <p>When a package provides a shell interpreter, it has to set the
5786: <code class="varname">PKG_SHELL</code> variable to its absolute file name. This will
5787: add some hooks to the installation scripts to handle it. Consider the
1.76 rillig 5788: following example, taken from <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/shells/zsh/README.html" target="_top"><code class="filename">shells/zsh</code></a>:</p>
1.75 rillig 5789: <pre class="programlisting">
5790: PKG_SHELL= ${PREFIX}/bin/zsh
1.1 grant 5791: </pre>
1.75 rillig 5792: <div class="sect2" lang="en">
5793: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 5794: <a name="shells-disable"></a>14.5.1. Disabling shell registration</h3></div></div></div>
1.75 rillig 5795: <p>The automatic registration of shell interpreters can be disabled by
1.76 rillig 5796: the administrator by setting the <code class="filename">PKG_REGISTER_SHELLS</code>
1.75 rillig 5797: environment variable to <code class="literal">NO</code>.</p>
5798: </div>
5799: </div>
5800: <div class="sect1" lang="en">
5801: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 5802: <a name="fonts"></a>14.6. Fonts</h2></div></div></div>
1.75 rillig 5803: <p>Packages that install X11 fonts should update the database files
5804: that index the fonts within each fonts directory. This can easily be
5805: accomplished within the pkginstall framework.</p>
5806: <p>When a package installs X11 fonts, it must list the directories in
5807: which fonts are installed in the
5808: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code> variables,
5809: where <em class="replaceable"><code>type</code></em> can be one of “<span class="quote">ttf</span>”,
5810: “<span class="quote">type1</span>” or “<span class="quote">x11</span>”. This will add hooks to the
5811: installation scripts to run the appropriate commands to update the fonts
5812: database files within each of those directories. For convenience, if the
5813: directory path is relative, it is taken to be relative to the package's
1.76 rillig 5814: installation prefix. Consider the following example, taken from <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/fonts/dbz-ttf/README.html" target="_top"><code class="filename">fonts/dbz-ttf</code></a>:</p>
1.75 rillig 5815: <pre class="programlisting">
5816: FONTS_DIRS.ttf= ${PREFIX}/lib/X11/fonts/TTF
1.1 grant 5817: </pre>
1.75 rillig 5818: <div class="sect2" lang="en">
5819: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 5820: <a name="fonts-disable"></a>14.6.1. Disabling automatic update of the fonts databases</h3></div></div></div>
1.75 rillig 5821: <p>The automatic update of fonts databases can be disabled by
1.76 rillig 5822: the administrator by setting the <code class="filename">PKG_UPDATE_FONTS_DB</code>
1.75 rillig 5823: environment variable to <code class="literal">NO</code>.</p>
5824: </div>
5825: </div>
5826: </div>
5827: <div class="chapter" lang="en">
5828: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 5829: <a name="options"></a>Chapter 15. Options handling</h2></div></div></div>
1.75 rillig 5830: <div class="toc">
5831: <p><b>Table of Contents</b></p>
5832: <dl>
1.90 ! rillig 5833: <dt><span class="sect1"><a href="#global-default-options">15.1. Global default options</a></span></dt>
! 5834: <dt><span class="sect1"><a href="#converting-to-options">15.2. Converting packages to use <code class="filename">bsd.options.mk</code></a></span></dt>
! 5835: <dt><span class="sect1"><a href="#option-names">15.3. Option Names</a></span></dt>
1.75 rillig 5836: </dl>
5837: </div>
5838: <p>Many packages have the ability to be built to support different
1.76 rillig 5839: sets of features. <code class="filename">bsd.options.mk</code> is a framework
1.75 rillig 5840: in pkgsrc that provides generic handling of those options that
5841: determine different ways in which the packages can be built. It's
5842: possible for the user to specify exactly which sets of options will be
5843: built into a package or to allow a set of global default options
5844: apply.</p>
5845: <div class="sect1" lang="en">
5846: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 5847: <a name="global-default-options"></a>15.1. Global default options</h2></div></div></div>
1.75 rillig 5848: <p>Global default options are listed in
5849: <code class="varname">PKG_DEFAULT_OPTIONS</code>, which is a list of the options
5850: that should be built into every package if that option is supported.
1.76 rillig 5851: This variable should be set in <code class="filename">/etc/mk.conf</code>.</p>
1.75 rillig 5852: </div>
5853: <div class="sect1" lang="en">
5854: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 5855: <a name="converting-to-options"></a>15.2. Converting packages to use <code class="filename">bsd.options.mk</code></h2></div></div></div>
1.75 rillig 5856: <p>The following example shows how
1.76 rillig 5857: <code class="filename">bsd.options.mk</code> should be used
1.75 rillig 5858: by the hypothetical ``wibble'' package, either in the package
1.76 rillig 5859: <code class="filename">Makefile</code>, or in a file,
5860: e.g. <code class="filename">options.mk</code>, that is included by the
5861: main package <code class="filename">Makefile</code>.</p>
1.75 rillig 5862: <pre class="programlisting">
5863: PKG_OPTIONS_VAR= PKG_OPTIONS.wibble
5864: PKG_SUPPORTED_OPTIONS= wibble-foo ldap
5865: PKG_OPTIONS_OPTIONAL_GROUPS= database
5866: PKG_OPTIONS_GROUP.database= mysql pgsql
5867: PKG_SUGGESTED_OPTIONS= wibble-foo
5868: PKG_OPTIONS_LEGACY_VARS+= WIBBLE_USE_OPENLDAP:ldap
5869: PKG_OPTIONS_LEGACY_OPTS+= foo:wibble-foo
1.1 grant 5870:
1.75 rillig 5871: .include "../../mk/bsd.prefs.mk"
1.69 rillig 5872:
1.75 rillig 5873: # this package was previously named wibble2
5874: .if defined(PKG_OPTIONS.wibble2)
5875: PKG_LEGACY_OPTIONS+= ${PKG_OPTIONS.wibble2}
5876: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
1.78 rillig 5877: "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
1.75 rillig 5878: .endif
1.69 rillig 5879:
1.75 rillig 5880: .include "../../mk/bsd.options.mk"
1.69 rillig 5881:
1.75 rillig 5882: # Package-specific option-handling
1.69 rillig 5883:
1.75 rillig 5884: ###
5885: ### FOO support
5886: ###
5887: .if !empty(PKG_OPTIONS:Mwibble-foo)
5888: CONFIGURE_ARGS+= --enable-foo
5889: .endif
1.69 rillig 5890:
1.75 rillig 5891: ###
5892: ### LDAP support
5893: ###
5894: .if !empty(PKG_OPTIONS:Mldap)
1.77 rillig 5895: . include "../../databases/openldap-client/buildlink3.mk"
5896: CONFIGURE_ARGS+= --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
1.75 rillig 5897: .endif
1.69 rillig 5898:
1.75 rillig 5899: ###
5900: ### database support
5901: ###
5902: .if !empty(PKG_OPTIONS:Mmysql)
5903: . include "../../mk/mysql.buildlink3.mk"
5904: .endif
5905: .if !empty(PKG_OPTIONS:Mpgsql)
5906: . include "../../mk/pgsql.buildlink3.mk"
5907: .endif
5908: </pre>
5909: <p>The first section contains the information about which build
5910: options are supported by the package, and any default options settings
5911: if needed.</p>
5912: <div class="orderedlist"><ol type="1">
5913: <li><p><code class="varname">PKG_OPTIONS_VAR</code> is the name of the
5914: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> variable that the user can set to override the default
5915: options. It should be set to
1.78 rillig 5916: PKG_OPTIONS.<em class="replaceable"><code>pkgbase</code></em>. Do not set it to
5917: PKG_OPTIONS.${PKGBASE}, since <code class="varname">PKGBASE</code> is not defined
5918: at the point where the options are processed.</p></li>
1.75 rillig 5919: <li><p><code class="varname">PKG_SUPPORTED_OPTIONS</code> is a list of
5920: build options supported by the package.</p></li>
5921: <li><p><code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code> is a
5922: list of names of groups of mutually exclusive options. The options in
5923: each group are listed in
5924: <code class="varname">PKG_OPTIONS_GROUP.<em class="replaceable"><code>groupname</code></em></code>.
5925: The most specific setting of any option from the group takes
5926: precedence over all other options in the group. Options from the
5927: groups will be automatically added to
5928: <code class="varname">PKG_SUPPORTED_OPTIONS</code>.</p></li>
5929: <li><p><code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> is like
5930: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, but building the
5931: packages will fail if no option from the group is
5932: selected.</p></li>
5933: <li><p><code class="varname">PKG_OPTIONS_NONEMPTY_SETS</code> is a list
5934: of names of sets of options. At least one option from each set must
5935: be selected. The options in each set are listed in
5936: <code class="varname">PKG_OPTIONS_SET.<em class="replaceable"><code>setname</code></em></code>.
5937: Options from the sets will be automatically added to
5938: <code class="varname">PKG_SUPPORTED_OPTIONS</code>. Building the package will
5939: fail if no option from the set is selected.</p></li>
5940: <li><p><code class="varname">PKG_SUGGESTED_OPTIONS</code> is a list of
5941: build options which are enabled by default.</p></li>
5942: <li><p><code class="varname">PKG_OPTIONS_LEGACY_VARS</code> is a list
5943: of
5944: “<span class="quote"><em class="replaceable"><code>USE_VARIABLE</code></em>:<em class="replaceable"><code>option</code></em></span>”
1.76 rillig 5945: pairs that map legacy <code class="filename">/etc/mk.conf</code> variables to
1.75 rillig 5946: their option counterparts. Pairs should be added with
5947: “<span class="quote">+=</span>” to keep the listing of global legacy variables. A
5948: warning will be issued if the user uses a legacy
5949: variable.</p></li>
5950: <li><p><code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> is a list
5951: of
5952: “<span class="quote"><em class="replaceable"><code>old-option</code></em>:<em class="replaceable"><code>new-option</code></em></span>”
5953: pairs that map options that have been renamed to their new
5954: counterparts. Pairs should be added with “<span class="quote">+=</span>” to keep
5955: the listing of global legacy options. A warning will be issued if
5956: the user uses a legacy option.</p></li>
5957: <li><p><code class="varname">PKG_LEGACY_OPTIONS</code> is a list of
5958: options implied by deprecated variables used. This can be used for
5959: cases that neither <code class="varname">PKG_OPTIONS_LEGACY_VARS</code> nor
5960: <code class="varname">PKG_OPTIONS_LEGACY_OPTS</code> can handle, e. g. when
5961: <code class="varname">PKG_OPTIONS_VAR</code> is renamed.</p></li>
5962: <li><p><code class="varname">PKG_OPTIONS_DEPRECATED_WARNINGS</code> is
5963: a list of warnings about deprecated variables or options used, and
5964: what to use instead.</p></li>
5965: </ol></div>
5966: <p>A package should never modify
5967: <code class="varname">PKG_DEFAULT_OPTIONS</code> or the variable named in
5968: <code class="varname">PKG_OPTIONS_VAR</code>. These are strictly user-settable.
5969: To suggest a default set of options, use
5970: <code class="varname">PKG_SUGGESTED_OPTIONS</code>.</p>
5971: <p><code class="varname">PKG_OPTIONS_VAR</code> must be defined before
1.76 rillig 5972: including <code class="filename">bsd.options.mk</code>. If none of
1.75 rillig 5973: <code class="varname">PKG_SUPPORTED_OPTIONS</code>,
5974: <code class="varname">PKG_OPTIONS_OPTIONAL_GROUPS</code>, and
5975: <code class="varname">PKG_OPTIONS_REQUIRED_GROUPS</code> are defined (as can
5976: happen with platform-specific options if none of them is supported on
5977: the current platform), <code class="varname">PKG_OPTIONS</code> is set to the
5978: empty list and the package is otherwise treated as not using the
5979: options framework.</p>
1.76 rillig 5980: <p>After the inclusion of <code class="filename">bsd.options.mk</code>, the
1.75 rillig 5981: variable <code class="varname">PKG_OPTIONS</code> contains the list of selected
5982: build options, properly filtered to remove unsupported and duplicate
5983: options.</p>
5984: <p>The remaining sections contain the logic that is specific to
5985: each option. The correct way to check for an option is to check
5986: whether it is listed in <code class="varname">PKG_OPTIONS</code>:</p>
5987: <pre class="programlisting">
5988: .if !empty(PKG_OPTIONS:M<em class="replaceable"><code>option</code></em>)
5989: </pre>
5990: </div>
5991: <div class="sect1" lang="en">
5992: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 5993: <a name="option-names"></a>15.3. Option Names</h2></div></div></div>
1.75 rillig 5994: <p>Options that enable similar features in different packages (like
5995: optional support for a library) should use a common name in all
5996: packages that support it (like the name of the library). If another
5997: package already has an option with the same meaning, use the same
5998: name.</p>
5999: <p>Options that enable features specific to one package, where it's
6000: unlikely that another (unrelated) package has the same (or a similar)
6001: optional feature, should use a name prefixed with
6002: <code class="varname"><em class="replaceable"><code>pkgname</code></em>-</code>.</p>
6003: <p>If a group of related packages share an optional feature
6004: specific to that group, prefix it with the name of the
6005: “<span class="quote">main</span>” package
6006: (e. g. <code class="varname">djbware-errno-hack</code>).</p>
6007: <p>For new options, add a line to
1.76 rillig 6008: <code class="filename">mk/defaults/options.description</code>. Lines have two
1.75 rillig 6009: fields, separated by tab. The first field is the option name, the
6010: second its description. The description should be a whole sentence
6011: (starting with an uppercase letter and ending with a period) that
6012: describes what enabling the option does. E. g. “<span class="quote">Enable ispell
6013: support.</span>” The file is sorted by option names.</p>
6014: </div>
6015: </div>
6016: <div class="chapter" lang="en">
6017: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 6018: <a name="build"></a>Chapter 16. The build process</h2></div></div></div>
1.75 rillig 6019: <div class="toc">
6020: <p><b>Table of Contents</b></p>
6021: <dl>
1.90 ! rillig 6022: <dt><span class="sect1"><a href="#build.intro">16.1. Introduction</a></span></dt>
! 6023: <dt><span class="sect1"><a href="#build.prefix">16.2. Program location</a></span></dt>
! 6024: <dt><span class="sect1"><a href="#build.builddirs">16.3. Directories used during the build process</a></span></dt>
! 6025: <dt><span class="sect1"><a href="#build.running">16.4. Running a phase</a></span></dt>
! 6026: <dt><span class="sect1"><a href="#build.fetch">16.5. The <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
! 6027: <dd><dl>
! 6028: <dt><span class="sect2"><a href="#build.fetch.what">16.5.1. What to fetch and where to get it from</a></span></dt>
! 6029: <dt><span class="sect2"><a href="#build.fetch.how">16.5.2. How are the files fetched?</a></span></dt>
! 6030: </dl></dd>
! 6031: <dt><span class="sect1"><a href="#build.checksum">16.6. The <span class="emphasis"><em>checksum</em></span> phase</a></span></dt>
! 6032: <dt><span class="sect1"><a href="#build.extract">16.7. The <span class="emphasis"><em>extract</em></span> phase</a></span></dt>
! 6033: <dt><span class="sect1"><a href="#build.patch">16.8. The <span class="emphasis"><em>patch</em></span> phase</a></span></dt>
! 6034: <dt><span class="sect1"><a href="#build.tools">16.9. The <span class="emphasis"><em>tools</em></span> phase</a></span></dt>
! 6035: <dt><span class="sect1"><a href="#build.wrapper">16.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
! 6036: <dt><span class="sect1"><a href="#build.configure">16.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
! 6037: <dt><span class="sect1"><a href="#build.build">16.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
! 6038: <dt><span class="sect1"><a href="#build.test">16.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
! 6039: <dt><span class="sect1"><a href="#build.install">16.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
! 6040: <dt><span class="sect1"><a href="#build.package">16.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
! 6041: <dt><span class="sect1"><a href="#build.clean">16.16. Cleaning up</a></span></dt>
! 6042: <dt><span class="sect1"><a href="#build.helpful-targets">16.17. Other helpful targets</a></span></dt>
1.75 rillig 6043: </dl>
6044: </div>
6045: <div class="sect1" lang="en">
6046: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6047: <a name="build.intro"></a>16.1. Introduction</h2></div></div></div>
1.75 rillig 6048: <p>This chapter gives a detailed description on how a package is
1.87 wiz 6049: built. Building a package is separated into different
6050: <span class="emphasis"><em>phases</em></span> (for example <code class="varname">fetch</code>,
6051: <code class="varname">build</code>, <code class="varname">install</code>), all of which are
6052: described in the following sections. Each phase is splitted into
6053: so-called <span class="emphasis"><em>stages</em></span>, which take the name of the
6054: containing phase, prefixed by one of <code class="varname">pre-</code>,
6055: <code class="varname">do-</code> or <code class="varname">post-</code>. (Examples are
6056: <code class="varname">pre-configure</code>, <code class="varname">post-build</code>.) Most
6057: of the actual work is done in the <code class="varname">do-*</code> stages.</p>
1.75 rillig 6058: <p>The basic steps for building a program are always the same. First
1.87 wiz 6059: the program's source (<span class="emphasis"><em>distfile</em></span>) must be brought to
6060: the local system and then extracted. After any pkgsrc-specific patches
6061: to compile properly are applied, the software can be configured, then
6062: built (usually by compiling), and finally the generated binaries, etc.
6063: can be put into place on the system.</p>
1.75 rillig 6064: </div>
6065: <div class="sect1" lang="en">
6066: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6067: <a name="build.prefix"></a>16.2. Program location</h2></div></div></div>
1.75 rillig 6068: <p>Before outlining the process performed by the NetBSD package system in
1.87 wiz 6069: the next section, here's a brief discussion on where programs are
6070: installed, and which variables influence this.</p>
1.75 rillig 6071: <p>The automatic variable <code class="varname">PREFIX</code> indicates
1.87 wiz 6072: where all files of the final program shall be installed. It is
6073: usually set to <code class="varname">LOCALBASE</code>
6074: (<code class="filename">/usr/pkg</code>), or <code class="varname">CROSSBASE</code>
1.88 wiz 6075: for pkgs in the <code class="filename">cross</code> category. The value of
1.87 wiz 6076: <code class="varname">PREFIX</code> needs to be put
6077: into the various places in the program's source where paths to
1.90 ! rillig 6078: these files are encoded. See <a href="#components.patches" title="10.3. patches/*">Section 10.3, “patches/*”</a> and <a href="#fixes.libtool" title="18.3.1. Shared libraries - libtool">Section 18.3.1, “Shared libraries - libtool”</a> for more details.</p>
1.75 rillig 6079: <p>When choosing which of these variables to use,
1.87 wiz 6080: follow the following rules:</p>
1.75 rillig 6081: <div class="itemizedlist"><ul type="disc">
1.88 wiz 6082: <li><p><code class="varname">PREFIX</code> always points to the location
6083: where the current pkg will be installed. When referring to a
6084: pkg's own installation path, use
6085: “<span class="quote">${PREFIX}</span>”.</p></li>
6086: <li><p><code class="varname">LOCALBASE</code> is where all non-X11 pkgs
6087: are installed. If you need to construct a -I or -L argument
6088: to the compiler to find includes and libraries installed by
6089: another non-X11 pkg, use “<span class="quote">${LOCALBASE}</span>”. The name
1.87 wiz 6090: <code class="varname">LOCALBASE</code> stems from FreeBSD, which
6091: installed all packages in <code class="filename">/usr/local</code>. As
6092: pkgsrc leaves <code class="filename">/usr/local</code> for the system
6093: administrator, this variable is a misnomer.</p></li>
1.88 wiz 6094: <li><p><code class="varname">X11BASE</code> is where the actual X11
6095: distribution (from xsrc, etc.) is installed. When looking for
6096: <span class="emphasis"><em>standard</em></span> X11 includes (not those
6097: installed by a package), use “<span class="quote">${X11BASE}</span>”.</p></li>
6098: <li>
6099: <p>X11-based packages are special in that they may be
6100: installed in either <code class="varname">X11BASE</code> or
6101: <code class="varname">LOCALBASE</code>.</p>
1.75 rillig 6102: <p>Usually, X11 packages should be installed under
1.88 wiz 6103: <code class="varname">LOCALBASE</code> whenever possible. Note that you
6104: will need to include
6105: <code class="filename">../../mk/x11.buildlink3.mk</code> in them to
6106: request the presence of X11 and to get the right compilation
6107: flags.</p>
1.75 rillig 6108: <p>Even though, there are some packages that cannot be installed
1.87 wiz 6109: under <code class="varname">LOCALBASE</code>: those that come with app-defaults
6110: files. These packages are special and they must be placed under
6111: <code class="varname">X11BASE</code>. To accomplish this, set either
6112: <code class="varname">USE_X11BASE</code> or <code class="varname">USE_IMAKE</code> in
6113: your package.</p>
1.75 rillig 6114: <p>Some notes: If you need
1.87 wiz 6115: to find includes or libraries installed by a pkg that has
6116: <code class="varname">USE_IMAKE</code> or <code class="varname">USE_X11BASE</code> in
6117: its pkg <code class="filename">Makefile</code>, you need to look in
6118: <span class="emphasis"><em>both</em></span> <code class="filename">${X11BASE}</code> and
6119: <code class="filename">${LOCALBASE}</code>. To force installation of
6120: all X11 packages in <code class="varname">LOCALBASE</code>, the
6121: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/xpkgwedge/README.html" target="_top"><code class="filename">pkgtools/xpkgwedge</code></a> package
6122: is enabled by default.</p>
1.75 rillig 6123: </li>
1.88 wiz 6124: <li><p><code class="varname">X11PREFIX</code> should be used to refer to
6125: the installed location of an X11
6126: package. <code class="varname">X11PREFIX</code> will be set to
6127: <code class="varname">X11BASE</code> if xpkgwedge is not installed, and
6128: to <code class="varname">LOCALBASE</code> if xpkgwedge is
6129: installed.</p></li>
6130: <li>
6131: <p>If xpkgwedge is installed, it is possible to have some
6132: packages installed in <code class="varname">X11BASE</code> and some in
6133: <code class="varname">LOCALBASE</code>. To determine the prefix of an
6134: installed package, the <code class="varname">EVAL_PREFIX</code>
6135: definition can be used. It takes pairs in the format
6136: “<span class="quote">DIRNAME=<package></span>”, and the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>
6137: variable <code class="varname">DIRNAME</code> will be set to the prefix
6138: of the installed package <package>, or
6139: “<span class="quote">${X11PREFIX}</span>” if the package is not
6140: installed.</p>
1.75 rillig 6141: <p>This is best illustrated by example.</p>
6142: <p>The following lines are taken from
1.87 wiz 6143: <code class="filename">pkgsrc/wm/scwm/Makefile</code>:</p>
1.75 rillig 6144: <pre class="programlisting">
1.87 wiz 6145: EVAL_PREFIX+= GTKDIR=gtk+
6146: CONFIGURE_ARGS+= --with-guile-prefix=${LOCALBASE:Q}
6147: CONFIGURE_ARGS+= --with-gtk-prefix=${GTKDIR:Q}
6148: CONFIGURE_ARGS+= --enable-multibyte
6149: </pre>
1.88 wiz 6150: <p>Specific defaults can be defined for the packages
6151: evaluated using <code class="varname">EVAL_PREFIX</code>, by using a
6152: definition of the form:</p>
1.75 rillig 6153: <pre class="programlisting">
1.87 wiz 6154: GTKDIR_DEFAULT= ${LOCALBASE}
6155: </pre>
1.75 rillig 6156: <p>where <code class="varname">GTKDIR</code> corresponds
1.87 wiz 6157: to the first definition in
6158: the <code class="varname">EVAL_PREFIX</code> pair.</p>
1.75 rillig 6159: </li>
1.76 rillig 6160: <li><p>Within <code class="filename">${PREFIX}</code>, packages should
1.87 wiz 6161: install files according to <a href="http://netbsd.gw.com/cgi-bin/man-cgi?hier+7+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">hier</span>(7)</span></a>, with the exception that
6162: manual pages go into <code class="filename">${PREFIX}/man</code>, not
6163: <code class="filename">${PREFIX}/share/man</code>.</p></li>
1.75 rillig 6164: </ul></div>
6165: </div>
6166: <div class="sect1" lang="en">
6167: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6168: <a name="build.builddirs"></a>16.3. Directories used during the build process</h2></div></div></div>
1.75 rillig 6169: <p>When building a package, a number of directories is used to store
1.87 wiz 6170: source files, temporary files, pkgsrc-internal files, and so on. These
6171: directories are explained here.</p>
1.75 rillig 6172: <p>Some of the directory variables contain relative pathnames. There
1.87 wiz 6173: are two common base directories for these relative directories:
6174: <code class="varname">PKGSRCDIR/PKGPATH</code> is used for directories that are
6175: pkgsrc-specific. <code class="varname">WRKSRC</code> is used for directories
6176: inside the package itself.</p>
1.75 rillig 6177: <div class="variablelist"><dl>
6178: <dt><span class="term"><code class="varname">PKGSRCDIR</code></span></dt>
6179: <dd><p>This is an absolute pathname that points to the pkgsrc
1.87 wiz 6180: root directory. Generally, you don't need
6181: it.</p></dd>
1.75 rillig 6182: <dt><span class="term"><code class="varname">PKGPATH</code></span></dt>
6183: <dd><p>This is a pathname relative to
1.87 wiz 6184: <code class="varname">PKGSRCDIR</code> that points to the current
6185: package.</p></dd>
1.75 rillig 6186: <dt><span class="term"><code class="varname">WRKDIR</code></span></dt>
6187: <dd><p>This is an absolute pathname pointing to the directory
1.87 wiz 6188: where all work takes place. The distfiles are extraced to this
6189: directory. It also contains temporary directories and log files used by
6190: the various pkgsrc frameworks, like <span class="emphasis"><em>buildlink</em></span> or
6191: the <span class="emphasis"><em>wrappers</em></span>.</p></dd>
1.75 rillig 6192: <dt><span class="term"><code class="varname">WRKSRC</code></span></dt>
6193: <dd><p>This is an absolute pathname pointing to the directory
1.87 wiz 6194: where the distfiles are extracted. It is usually a direct subdirectory
6195: of <code class="varname">WRKDIR</code>, and often it's the only directory entry
6196: that isn't hidden. This variable may be changed by a package
6197: <code class="filename">Makefile</code>.</p></dd>
1.75 rillig 6198: </dl></div>
6199: </div>
6200: <div class="sect1" lang="en">
6201: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6202: <a name="build.running"></a>16.4. Running a phase</h2></div></div></div>
1.75 rillig 6203: <p>You can run a particular phase by typing <span><strong class="command">make
1.87 wiz 6204: phase</strong></span>, where <span class="emphasis"><em>phase</em></span> is the name of the
6205: phase. This will automatically run all phases that are required for this
6206: phase. The default phase is <code class="varname">build</code>, that is, when you
6207: run <span><strong class="command">make</strong></span> without parameters in a package directory,
6208: the package will be built, but not installed.</p>
1.75 rillig 6209: </div>
6210: <div class="sect1" lang="en">
6211: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6212: <a name="build.fetch"></a>16.5. The <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.81 rillig 6213: <p>The first step in building a package is to fetch the
1.88 wiz 6214: distribution files (distfiles) from the sites that are providing
6215: them. This is the task of the <span class="emphasis"><em>fetch</em></span>
6216: phase.</p>
1.81 rillig 6217: <div class="sect2" lang="en">
6218: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 6219: <a name="build.fetch.what"></a>16.5.1. What to fetch and where to get it from</h3></div></div></div>
1.88 wiz 6220: <p>In simple cases, <code class="varname">MASTER_SITES</code>
6221: defines all URLs from where the distfile, whose name is
6222: derived from the <code class="varname">DISTNAME</code> variable, is
6223: fetched. The more complicated cases are described
6224: below.</p>
6225: <p>The variable <code class="varname">DISTFILES</code> specifies
6226: the list of distfiles that have to be fetched. Its value
6227: defaults to <code class="literal">${DISTNAME}${EXTRACT_SUFX}</code>,
6228: so that most packages don't need to define it at all.
6229: <code class="varname">EXTRACT_SUFX</code> is
6230: <code class="literal">.tar.gz</code> by default, but can be changed
6231: freely. Note that if your package requires additional
6232: distfiles to the default one, you cannot just append the
6233: additional filenames using the <code class="literal">+=</code>
6234: operator, but you have write for example:</p>
1.81 rillig 6235: <pre class="programlisting">
1.88 wiz 6236: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
6237: </pre>
6238: <p>Each distfile is fetched from a list of sites, usually
6239: <code class="varname">MASTER_SITES</code>. If the package has multiple
6240: <code class="varname">DISTFILES</code> or multiple
6241: <code class="varname">PATCHFILES</code> from different sites, you can
6242: set
6243: <code class="varname">SITES.<em class="replaceable"><code>distfile</code></em></code>
6244: to the list of URLs where the file
6245: <code class="filename"><em class="replaceable"><code>distfile</code></em></code>
6246: (including the suffix) can be found.</p>
6247: <pre class="programlisting">
6248: DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
6249: DISTFILES+= foo-file.tar.gz
6250: SITES.foo-file.tar.gz= \
6251: http://www.somewhere.com/somehow/ \
6252: http://www.somewhereelse.com/mirror/somehow/
6253: </pre>
1.81 rillig 6254: <p>When actually fetching the distfiles, each item from
1.88 wiz 6255: <code class="varname">MASTER_SITES</code> or
6256: <code class="varname">SITES.*</code> gets the name of each distfile
6257: appended to it, without an intermediate slash. Therefore,
6258: all site values have to end with a slash or other separator
6259: character. This allows for example to set
6260: <code class="varname">MASTER_SITES</code> to a URL of a CGI script
6261: that gets the name of the distfile as a parameter. In this
6262: case, the definition would look like:</p>
1.81 rillig 6263: <pre class="programlisting">
1.88 wiz 6264: MASTER_SITES= http://www.example.com/download.cgi?file=
6265: </pre>
1.81 rillig 6266: <p>There are some predefined values for
1.88 wiz 6267: <code class="varname">MASTER_SITES</code>, which can be used in
6268: packages. The names of the variables should speak for
6269: themselves.</p>
6270: <pre class="programlisting">
6271: ${MASTER_SITE_APACHE}
6272: ${MASTER_SITE_BACKUP}
6273: ${MASTER_SITE_CYGWIN}
6274: ${MASTER_SITE_DEBIAN}
6275: ${MASTER_SITE_FREEBSD}
6276: ${MASTER_SITE_FREEBSD_LOCAL}
6277: ${MASTER_SITE_GNOME}
6278: ${MASTER_SITE_GNU}
6279: ${MASTER_SITE_GNUSTEP}
6280: ${MASTER_SITE_IFARCHIVE}
6281: ${MASTER_SITE_KDE}
6282: ${MASTER_SITE_MOZILLA}
6283: ${MASTER_SITE_MYSQL}
6284: ${MASTER_SITE_OPENOFFICE}
6285: ${MASTER_SITE_PERL_CPAN}
6286: ${MASTER_SITE_PGSQL}
6287: ${MASTER_SITE_R_CRAN}
6288: ${MASTER_SITE_SOURCEFORGE}
6289: ${MASTER_SITE_SOURCEFORGE_JP}
6290: ${MASTER_SITE_SUNSITE}
6291: ${MASTER_SITE_SUSE}
6292: ${MASTER_SITE_TEX_CTAN}
6293: ${MASTER_SITE_XCONTRIB}
6294: ${MASTER_SITE_XEMACS}
6295: </pre>
6296: <p>Some explanations for the less self-explaining ones:
6297: <code class="varname">MASTER_SITE_BACKUP</code> contains backup sites
6298: for packages that are maintained in <a href="ftp://ftp.NetBSD.org:/pub/NetBSD/packages/distfiles/%24%7BDIST_SUBDIR%7D" target="_top">ftp://ftp.NetBSD.org:/pub/NetBSD/packages/distfiles/${DIST_SUBDIR}</a>. <code class="varname">MASTER_SITE_LOCAL</code> contains local
6299: package source distributions that are maintained in <a href="ftp://ftp.NetBSD.org:/pub/NetBSD/packages/distfiles/LOCAL_PORTS/" target="_top">ftp://ftp.NetBSD.org:/pub/NetBSD/packages/distfiles/LOCAL_PORTS/</a>.</p>
6300: <p>If you choose one of these predefined sites, you may
6301: want to specify a subdirectory of that site. Since these
6302: macros may expand to more than one actual site, you
6303: <span class="emphasis"><em>must</em></span> use the following construct to
6304: specify a subdirectory:</p>
1.81 rillig 6305: <pre class="programlisting">
1.88 wiz 6306: MASTER_SITES= ${MASTER_SITE_GNU:=subdirectory/name/}
6307: MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=project_name/}
6308: </pre>
1.81 rillig 6309: <p>Note the trailing slash after the subdirectory
1.88 wiz 6310: name.</p>
1.81 rillig 6311: </div>
6312: <div class="sect2" lang="en">
6313: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 6314: <a name="build.fetch.how"></a>16.5.2. How are the files fetched?</h3></div></div></div>
1.88 wiz 6315: <p>The <span class="emphasis"><em>fetch</em></span> phase makes sure that
6316: all the distfiles exist in a local directory
6317: (<code class="varname">DISTDIR</code>), which can be set by the pkgsrc
6318: user). If the files do not exist, they are fetched using
6319: commands of the form</p>
1.75 rillig 6320: <pre class="programlisting">
1.88 wiz 6321: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
6322: </pre>
6323: <p>where <code class="literal">${site}</code> varies through
6324: several possibilities in turn: first,
6325: <code class="varname">MASTER_SITE_OVERRIDE</code> is tried, then the
6326: sites specified in either <code class="varname">SITES.file</code> if
6327: defined, else <code class="varname">MASTER_SITES</code> or
6328: <code class="varname">PATCH_SITES</code>, as applies, then finally the
6329: value of <code class="varname">MASTER_SITE_BACKUP</code>. The order of
6330: all except the first can be optionally sorted by the user,
6331: via setting either <code class="varname">MASTER_SORT_AWK</code> or
6332: <code class="varname">MASTER_SORT_REGEX</code>.</p>
1.81 rillig 6333: </div>
1.75 rillig 6334: </div>
6335: <div class="sect1" lang="en">
6336: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6337: <a name="build.checksum"></a>16.6. The <span class="emphasis"><em>checksum</em></span> phase</h2></div></div></div>
1.88 wiz 6338: <p>After the distfile(s) are fetched, their checksum is
6339: generated and compared with the checksums stored in the
6340: distinfo file. If the checksums don't match, the build is
6341: aborted. This is to ensure the same distfile is used for
6342: building, and that the distfile wasn't changed, e.g. by some
6343: malign force, deliberately changed distfiles on the master
6344: distribution site or network lossage.</p>
1.75 rillig 6345: </div>
6346: <div class="sect1" lang="en">
6347: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6348: <a name="build.extract"></a>16.7. The <span class="emphasis"><em>extract</em></span> phase</h2></div></div></div>
1.75 rillig 6349: <p>When the distfiles are present on the local system, they
1.88 wiz 6350: need to be extracted, as they usually come in the form of some
6351: compressed archive format.</p>
1.75 rillig 6352: <p>By default, all <code class="varname">DISTFILES</code> are
1.88 wiz 6353: extracted. If you only need some of them, you can set the
6354: <code class="varname">EXTRACT_ONLY</code> variable to the list of those
6355: files.</p>
6356: <p>Extracting the files is usually done by a little
6357: program, <code class="filename">mk/scripts/extract</code>, which
6358: already knows how to extract various archive formats, so most
6359: likely you will not need to change anything here. But if you
6360: need, the following variables may help you:</p>
1.75 rillig 6361: <div class="variablelist"><dl>
6362: <dt><span class="term"><code class="varname">EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}</code></span></dt>
6363: <dd><p>Use these variables to override the default
1.88 wiz 6364: options for an extract command, which are defined in
6365: <code class="filename">mk/scripts/extract</code>.</p></dd>
1.75 rillig 6366: <dt><span class="term"><code class="varname">EXTRACT_USING</code></span></dt>
6367: <dd><p>This variable can be set to
1.88 wiz 6368: <code class="literal">pax</code>, <code class="literal">tar</code> or an
6369: absolute pathname pointing to the command with which tar
6370: archives should be
6371: extracted.</p></dd>
1.75 rillig 6372: </dl></div>
1.88 wiz 6373: <p>If the <code class="filename">extract</code> program doesn't
6374: serve your needs, you can also override the
6375: <code class="varname">EXTRACT_CMD</code> variable, which holds the
6376: command used for extracting the files. This command is
6377: executed in the <code class="filename">${WRKSRC}</code>
6378: directory. During execution of this command, the shell
6379: variable <code class="varname">extract_file</code> holds the absolute
6380: pathname of the file that is going to be extracted.</p>
1.75 rillig 6381: <p>And if that still does not suffice, you can override the
1.88 wiz 6382: <code class="varname">do-extract</code> target in the package
6383: Makefile.</p>
1.75 rillig 6384: </div>
6385: <div class="sect1" lang="en">
6386: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6387: <a name="build.patch"></a>16.8. The <span class="emphasis"><em>patch</em></span> phase</h2></div></div></div>
1.75 rillig 6388: <p>After extraction, all the patches named by the
1.88 wiz 6389: <code class="varname">PATCHFILES</code>, those present in the patches
6390: subdirectory of the package as well as in
6391: $LOCALPATCHES/$PKGPATH (e.g.
6392: <code class="filename">/usr/local/patches/graphics/png</code>) are
6393: applied. Patchfiles ending in <code class="filename">.Z</code> or
6394: <code class="filename">.gz</code> are uncompressed before they are
6395: applied, files ending in <code class="filename">.orig</code> or
6396: <code class="filename">.rej</code> are ignored. Any special options to
6397: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?patch+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">patch</span>(1)</span></a> can be handed in
1.90 ! rillig 6398: <code class="varname">PATCH_DIST_ARGS</code>. See <a href="#components.patches" title="10.3. patches/*">Section 10.3, “patches/*”</a> for more details.</p>
1.88 wiz 6399: <p>By default <a href="http://netbsd.gw.com/cgi-bin/man-cgi?patch+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">patch</span>(1)</span></a> is given special args to make
6400: it fail if the patches apply with some lines of fuzz. Please
6401: fix (regen) the patches so that they apply cleanly. The
6402: rationale behind this is that patches that don't apply cleanly
6403: may end up being applied in the wrong place, and cause severe
6404: harm there.</p>
1.75 rillig 6405: </div>
6406: <div class="sect1" lang="en">
6407: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6408: <a name="build.tools"></a>16.9. The <span class="emphasis"><em>tools</em></span> phase</h2></div></div></div>
! 6409: <p>This is covered in <a href="#tools" title="Chapter 17. Tools needed for building or running">Chapter 17, <i>Tools needed for building or running</i></a>.
1.88 wiz 6410: </p>
1.75 rillig 6411: </div>
6412: <div class="sect1" lang="en">
6413: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6414: <a name="build.wrapper"></a>16.10. The <span class="emphasis"><em>wrapper</em></span> phase</h2></div></div></div>
1.75 rillig 6415: <p>This phase creates wrapper programs for the compilers and
1.88 wiz 6416: linkers. The following variables can be used to tweak the
6417: wrappers.</p>
1.75 rillig 6418: <div class="variablelist"><dl>
6419: <dt><span class="term"><code class="varname">ECHO_WRAPPER_MSG</code></span></dt>
6420: <dd><p>The command used to print progress
1.88 wiz 6421: messages. Does nothing by default. Set to
6422: <code class="literal">${ECHO}</code> to see the progress
6423: messages.</p></dd>
1.75 rillig 6424: <dt><span class="term"><code class="varname">WRAPPER_DEBUG</code></span></dt>
6425: <dd><p>This variable can be set to
1.88 wiz 6426: <code class="literal">yes</code> (default) or <code class="literal">no</code>,
6427: depending on whether you want additional information in the
6428: wrapper log file.</p></dd>
1.75 rillig 6429: <dt><span class="term"><code class="varname">WRAPPER_UPDATE_CACHE</code></span></dt>
6430: <dd><p>This variable can be set to
1.88 wiz 6431: <code class="literal">yes</code> or <code class="literal">no</code>, depending
6432: on whether the wrapper should use its cache, which will
6433: improve the speed. The default value is
6434: <code class="literal">yes</code>, but is forced to
6435: <code class="literal">no</code> if the platform does not support
6436: it.</p></dd>
1.75 rillig 6437: <dt><span class="term"><code class="varname">WRAPPER_REORDER_CMDS</code></span></dt>
1.88 wiz 6438: <dd><p>A list of reordering commands. A reordering
6439: command has the form
6440: <code class="literal">reorder:l:<em class="replaceable"><code>lib1</code></em>:<em class="replaceable"><code>lib2</code></em></code>.
6441: It ensures that that
6442: <code class="literal">-l<em class="replaceable"><code>lib1</code></em></code> occurs
6443: before <code class="literal">-l<em class="replaceable"><code>lib2</code></em></code>.
6444: </p></dd>
1.75 rillig 6445: <dt><span class="term"><code class="varname">WRAPPER_TRANSFORM_CMDS</code></span></dt>
6446: <dd><p>A list of transformation commands. [TODO:
1.88 wiz 6447: investigate further]</p></dd>
1.75 rillig 6448: </dl></div>
6449: </div>
6450: <div class="sect1" lang="en">
6451: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6452: <a name="build.configure"></a>16.11. The <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.88 wiz 6453: <p>Most pieces of software need information on the header
6454: files, system calls, and library routines which are available
6455: on the platform they run on. The process of determining this
6456: information is known as configuration, and is usually
6457: automated. In most cases, a script is supplied with the
6458: distfiles, and its invocation results in generation of header
6459: files, Makefiles, etc.</p>
6460: <p>If the package contains a configure script, this can be
6461: invoked by setting <code class="varname">HAS_CONFIGURE</code> to
6462: “<span class="quote">yes</span>”. If the configure script is a GNU autoconf
6463: script, you should set <code class="varname">GNU_CONFIGURE</code> to
6464: “<span class="quote">yes</span>” instead. What happens in the
6465: <span class="emphasis"><em>configure</em></span> phase is roughly:</p>
6466: <pre class="programlisting">
6467: .for d in ${CONFIGURE_DIRS}
6468: cd ${WRKSRC} && cd ${d} && env ${CONFIGURE_ENV} \
6469: ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
6470: .endfor
6471: </pre>
6472: <p><code class="varname">CONFIGURE_DIRS</code> (default:
6473: “<span class="quote">.</span>”) is a list of pathnames relative to
6474: <code class="varname">WRKSRC</code>. In each of these directories, the
6475: configure script is run with the environment
6476: <code class="varname">CONFIGURE_ENV</code> and arguments
6477: <code class="varname">CONFIGURE_ARGS</code>. The variables
6478: <code class="varname">CONFIGURE_ENV</code>,
6479: <code class="varname">CONFIGURE_SCRIPT</code> (default:
6480: “<span class="quote">./configure</span>”) and
6481: <code class="varname">CONFIGURE_ARGS</code> may all be changed by the
6482: package.</p>
6483: <p>If the program uses an <code class="filename">Imakefile</code>
6484: for configuration, the appropriate steps can be invoked by
6485: setting <code class="varname">USE_IMAKE</code> to
6486: “<span class="quote">yes</span>”. (If you only want the package installed in
6487: <code class="varname">${X11PREFIX}</code> but xmkmf not being run, set
6488: <code class="varname">USE_X11BASE</code> instead.)</p>
1.75 rillig 6489: </div>
6490: <div class="sect1" lang="en">
6491: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6492: <a name="build.build"></a>16.12. The <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.88 wiz 6493: <p>For building a package, a rough equivalent of the
6494: following code is executed.</p>
1.75 rillig 6495: <pre class="programlisting">
1.88 wiz 6496: .for d in ${BUILD_DIRS}
6497: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
6498: ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
6499: -f ${MAKE_FILE} ${BUILD_TARGET}
6500: .endfor
6501: </pre>
6502: <p><code class="varname">BUILD_DIRS</code> (default:
6503: “<span class="quote">.</span>”) is a list of pathnames relative to
6504: <code class="varname">WRKSRC</code>. In each of these directories,
6505: <code class="varname">MAKE_PROGRAM</code> is run with the environment
6506: <code class="varname">MAKE_ENV</code> and arguments
6507: <code class="varname">BUILD_MAKE_FLAGS</code>. The variables
6508: <code class="varname">MAKE_ENV</code>,
6509: <code class="varname">BUILD_MAKE_FLAGS</code>,
6510: <code class="varname">MAKE_FILE</code> and
6511: <code class="varname">BUILD_TARGET</code> may all be changed by the
6512: package.</p>
1.75 rillig 6513: <p>The default value of <code class="varname">MAKE_PROGRAM</code> is
1.88 wiz 6514: “<span class="quote">gmake</span>” if <code class="varname">USE_TOOLS</code> contains
6515: “<span class="quote">gmake</span>”, “<span class="quote">make</span>” otherwise. The
6516: default value of <code class="varname">MAKE_FILE</code> is
6517: “<span class="quote">Makefile</span>”, and <code class="varname">BUILD_TARGET</code>
6518: defaults to “<span class="quote">all</span>”.</p>
1.75 rillig 6519: </div>
6520: <div class="sect1" lang="en">
6521: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6522: <a name="build.test"></a>16.13. The <span class="emphasis"><em>test</em></span> phase</h2></div></div></div>
1.75 rillig 6523: <p>[TODO]</p>
6524: </div>
6525: <div class="sect1" lang="en">
6526: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6527: <a name="build.install"></a>16.14. The <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75 rillig 6528: <p>Once the build stage has completed, the final step is to
1.88 wiz 6529: install the software in public directories, so users can
6530: access the programs and files.</p>
1.75 rillig 6531: <p>In the <span class="emphasis"><em>install</em></span> phase, a rough
1.88 wiz 6532: equivalent of the following code is executed. Additionally,
6533: before and after this code, much magic is performed to do
6534: consistency checks, registering the package, and so on.</p>
6535: <pre class="programlisting">
6536: .for d in ${INSTALL_DIRS}
6537: cd ${WRKSRC} && cd ${d} && env ${MAKE_ENV} \
6538: ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
6539: -f ${MAKE_FILE} ${BUILD_TARGET}
6540: .endfor
6541: </pre>
1.75 rillig 6542: <p>The variable's meanings are analogous to the ones in the
1.88 wiz 6543: <span class="emphasis"><em>build</em></span> phase.
6544: <code class="varname">INSTALL_DIRS</code> defaults to
6545: <code class="varname">BUILD_DIRS</code>. <code class="varname">INSTALL_TARGET</code>
6546: is “<span class="quote">install</span>” by default, plus
6547: “<span class="quote">install.man</span>” if <code class="varname">USE_IMAKE</code> is
6548: defined and <code class="varname">NO_INSTALL_MANPAGES</code> is not
6549: defined.</p>
1.75 rillig 6550: <p>In the <span class="emphasis"><em>install</em></span> phase, the following
1.88 wiz 6551: variables are useful. They are all variations of the
6552: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?install+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">install</span>(1)</span></a> command that have the owner, group and
6553: permissions preset. <code class="varname">INSTALL</code> is the plain
6554: install command. The specialized variants, together with their
6555: intended use, are:</p>
1.75 rillig 6556: <div class="variablelist"><dl>
6557: <dt><span class="term"><code class="varname">INSTALL_PROGRAM_DIR</code></span></dt>
1.88 wiz 6558: <dd><p>directories that contain
6559: binaries</p></dd>
1.75 rillig 6560: <dt><span class="term"><code class="varname">INSTALL_SCRIPT_DIR</code></span></dt>
1.88 wiz 6561: <dd><p>directories that contain
6562: scripts</p></dd>
1.75 rillig 6563: <dt><span class="term"><code class="varname">INSTALL_LIB_DIR</code></span></dt>
1.88 wiz 6564: <dd><p>directories that contain shared and static
6565: libraries</p></dd>
1.75 rillig 6566: <dt><span class="term"><code class="varname">INSTALL_DATA_DIR</code></span></dt>
1.88 wiz 6567: <dd><p>directories that contain data
6568: files</p></dd>
1.75 rillig 6569: <dt><span class="term"><code class="varname">INSTALL_MAN_DIR</code></span></dt>
1.88 wiz 6570: <dd><p>directories that contain man
6571: pages</p></dd>
1.75 rillig 6572: <dt><span class="term"><code class="varname">INSTALL_PROGRAM</code></span></dt>
1.88 wiz 6573: <dd><p>binaries that can be stripped from debugging
6574: symbols</p></dd>
1.75 rillig 6575: <dt><span class="term"><code class="varname">INSTALL_SCRIPT</code></span></dt>
1.88 wiz 6576: <dd><p>binaries that cannot be
6577: stripped</p></dd>
1.75 rillig 6578: <dt><span class="term"><code class="varname">INSTALL_GAME</code></span></dt>
1.88 wiz 6579: <dd><p>game
6580: binaries</p></dd>
1.75 rillig 6581: <dt><span class="term"><code class="varname">INSTALL_LIB</code></span></dt>
1.88 wiz 6582: <dd><p>shared and static
6583: libraries</p></dd>
1.75 rillig 6584: <dt><span class="term"><code class="varname">INSTALL_DATA</code></span></dt>
6585: <dd><p>data files</p></dd>
6586: <dt><span class="term"><code class="varname">INSTALL_GAME_DATA</code></span></dt>
1.88 wiz 6587: <dd><p>data files for
6588: games</p></dd>
1.75 rillig 6589: <dt><span class="term"><code class="varname">INSTALL_MAN</code></span></dt>
6590: <dd><p>man pages</p></dd>
6591: </dl></div>
6592: <p>Some other variables are:</p>
6593: <div class="variablelist"><dl>
6594: <dt><span class="term"><code class="varname">INSTALLATION_DIRS</code></span></dt>
6595: <dd><p>A list of directories relative to
1.88 wiz 6596: <code class="varname">PREFIX</code> that are created by pkgsrc at the
6597: beginning of the <span class="emphasis"><em>install</em></span> phase. If
6598: this variable is set,
6599: <code class="varname">NO_MTREE</code>=“<span class="quote">yes</span>” is assumed,
6600: which means that the package claims to create all needed
6601: directories itself before installing files to it. Therefore
6602: this variable should only be set in
6603: <code class="filename">Makefile</code>s that are under control of the
6604: package's author. The directories are created with the
6605: correct ownership, depending on their
6606: name.</p></dd>
1.75 rillig 6607: </dl></div>
6608: </div>
6609: <div class="sect1" lang="en">
6610: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6611: <a name="build.package"></a>16.15. The <span class="emphasis"><em>package</em></span> phase</h2></div></div></div>
1.88 wiz 6612: <p>Once the install stage has completed, a binary package of
6613: the installed files can be built. These binary packages can be
6614: used for quick installation without previous compilation, e.g. by
6615: the <span><strong class="command">make bin-install</strong></span> or by using
6616: <span><strong class="command">pkg_add</strong></span>.</p>
6617: <p>By default, the binary packages are created in
6618: <code class="filename">${PACKAGES}/All</code> and symlinks are created in
6619: <code class="filename">${PACKAGES}/<em class="replaceable"><code>category</code></em></code>,
6620: one for each category in the <code class="varname">CATEGORIES</code>
6621: variable. <code class="varname">PACKAGES</code> defaults to
6622: <code class="filename">pkgsrc/packages</code>.</p>
6623: </div>
6624: <div class="sect1" lang="en">
6625: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6626: <a name="build.clean"></a>16.16. Cleaning up</h2></div></div></div>
1.88 wiz 6627: <p>Once you're finished with a package, you can clean the work
6628: directory by running <span><strong class="command">make clean</strong></span>. If you want
6629: to clean the work directories of all dependencies too, use
6630: <span><strong class="command">make clean-depends</strong></span>.</p>
1.75 rillig 6631: </div>
6632: <div class="sect1" lang="en">
6633: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 6634: <a name="build.helpful-targets"></a>16.17. Other helpful targets</h2></div></div></div>
1.75 rillig 6635: <div class="variablelist"><dl>
6636: <dt><span class="term">pre/post-*</span></dt>
1.88 wiz 6637: <dd><p>For any of the main targets described in the
6638: previous section, two auxiliary targets exist with
1.87 wiz 6639: “<span class="quote">pre-</span>” and “<span class="quote">post-</span>” used as a
6640: prefix for the main target's name. These targets are
1.88 wiz 6641: invoked before and after the main target is called,
6642: allowing extra configuration or installation steps be
6643: performed from a package's Makefile, for example, which
6644: a program's configure script or install target
6645: omitted.</p></dd>
1.75 rillig 6646: <dt><span class="term">do-*</span></dt>
1.88 wiz 6647: <dd><p>Should one of the main targets do the wrong thing,
6648: and should there be no variable to fix this, you can
6649: redefine it with the do-* target. (Note that redefining
6650: the target itself instead of the do-* target is a bad
6651: idea, as the pre-* and post-* targets won't be called
6652: anymore, etc.) You will not usually need to do
6653: this.</p></dd>
1.75 rillig 6654: <dt><span class="term">reinstall</span></dt>
1.88 wiz 6655: <dd>
6656: <p>If you did a <span><strong class="command">make install</strong></span> and
6657: you noticed some file was not installed properly, you
6658: can repeat the installation with this target, which will
6659: ignore the “<span class="quote">already installed</span>” flag.</p>
6660: <p>This is the default value of
6661: <code class="varname">DEPENDS_TARGET</code> except in the case of
6662: <span><strong class="command">make update</strong></span> and <span><strong class="command">make
6663: package</strong></span>, where the defaults are
6664: “<span class="quote">package</span>” and “<span class="quote">update</span>”,
6665: respectively.</p>
6666: </dd>
1.75 rillig 6667: <dt><span class="term">deinstall</span></dt>
6668: <dd>
1.88 wiz 6669: <p>This target does a <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a> in the
6670: current directory, effectively de-installing the
6671: package. The following variables can be used to tune the
6672: behaviour:</p>
1.75 rillig 6673: <div class="variablelist"><dl>
6674: <dt><span class="term"><code class="varname">PKG_VERBOSE</code></span></dt>
6675: <dd><p>Add a "-v" to the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a> command.</p></dd>
6676: <dt><span class="term"><code class="varname">DEINSTALLDEPENDS</code></span></dt>
1.88 wiz 6677: <dd><p>Remove all packages that require (depend on)
6678: the given package. This can be used to remove any
6679: packages that may have been pulled in by a given
6680: package, e.g. if <span><strong class="command">make deinstall
1.87 wiz 6681: DEINSTALLDEPENDS=1</strong></span> is done in
1.88 wiz 6682: <code class="filename">pkgsrc/x11/kde</code>, this is
6683: likely to remove whole KDE. Works by adding
6684: “<span class="quote">-R</span>” to the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a>
6685: command line.</p></dd>
1.75 rillig 6686: </dl></div>
6687: </dd>
1.88 wiz 6688: <dt><span class="term">bin-install</span></dt>
6689: <dd><p>Install a binary package from local disk and via FTP
6690: from a list of sites (see the
6691: <code class="varname">BINPKG_SITES</code> variable), and do a
6692: <span><strong class="command">make package</strong></span> if no binary package is
6693: available anywhere. The arguments given to
6694: <span><strong class="command">pkg_add</strong></span> can be set via
6695: <code class="varname">BIN_INSTALL_FLAGS</code> e.g., to do verbose
6696: operation, etc.</p></dd>
1.75 rillig 6697: <dt><span class="term">update</span></dt>
6698: <dd>
1.88 wiz 6699: <p>This target causes the current package to be
6700: updated to the latest version. The package and all
6701: depending packages first get de-installed, then current
6702: versions of the corresponding packages get compiled and
6703: installed. This is similar to manually noting which
6704: packages are currently installed, then performing a
6705: series of <span><strong class="command">make deinstall</strong></span> and
6706: <span><strong class="command">make install</strong></span> (or whatever
6707: <code class="varname">UPDATE_TARGET</code> is set to) for these
6708: packages.</p>
6709: <p>You can use the “<span class="quote">update</span>” target to
6710: resume package updating in case a previous <span><strong class="command">make
6711: update</strong></span> was interrupted for some reason.
6712: However, in this case, make sure you don't call
6713: <span><strong class="command">make clean</strong></span> or otherwise remove the
6714: list of dependent packages in <code class="varname">WRKDIR</code>.
6715: Otherwise, you lose the ability to automatically update
6716: the current package along with the dependent packages
6717: you have installed.</p>
6718: <p>Resuming an interrupted <span><strong class="command">make
6719: update</strong></span> will only work as long as the package
6720: tree remains unchanged. If the source code for one of
6721: the packages to be updated has been changed, resuming
6722: <span><strong class="command">make update</strong></span> will most certainly
6723: fail!</p>
6724: <p>The following variables can be used either on the
6725: command line or in <code class="filename">/etc/mk.conf</code> to
6726: alter the behaviour of <span><strong class="command">make
6727: update</strong></span>:</p>
1.75 rillig 6728: <div class="variablelist"><dl>
6729: <dt><span class="term"><code class="varname">UPDATE_TARGET</code></span></dt>
1.88 wiz 6730: <dd><p>Install target to recursively use for the
6731: updated package and the dependent packages.
6732: Defaults to <code class="varname">DEPENDS_TARGET</code> if
6733: set, “<span class="quote">install</span>” otherwise for
6734: <span><strong class="command">make update</strong></span>. Other good
6735: targets are “<span class="quote">package</span>” or
6736: “<span class="quote">bin-install</span>”. Do not set this to
6737: “<span class="quote">update</span>” or you will get stuck in an
6738: endless loop!</p></dd>
1.75 rillig 6739: <dt><span class="term"><code class="varname">NOCLEAN</code></span></dt>
1.88 wiz 6740: <dd><p>Don't clean up after updating. Useful if
6741: you want to leave the work sources of the updated
6742: packages around for inspection or other purposes.
6743: Be sure you eventually clean up the source tree
6744: (see the “<span class="quote">clean-update</span>” target below)
6745: or you may run into troubles with old source code
6746: still lying around on your next
6747: <span><strong class="command">make</strong></span> or <span><strong class="command">make
6748: update</strong></span>.</p></dd>
1.75 rillig 6749: <dt><span class="term"><code class="varname">REINSTALL</code></span></dt>
1.88 wiz 6750: <dd><p>Deinstall each package before installing
6751: (making <code class="varname">DEPENDS_TARGET</code>). This
6752: may be necessary if the
6753: “<span class="quote">clean-update</span>” target (see below) was
6754: called after interrupting a running <span><strong class="command">make
6755: update</strong></span>.</p></dd>
1.75 rillig 6756: <dt><span class="term"><code class="varname">DEPENDS_TARGET</code></span></dt>
1.88 wiz 6757: <dd><p>Allows you to disable recursion and hardcode
6758: the target for packages. The default is
6759: “<span class="quote">update</span>” for the update target,
6760: facilitating a recursive update of prerequisite
6761: packages. Only set
6762: <code class="varname">DEPENDS_TARGET</code> if you want to
6763: disable recursive updates. Use
6764: <code class="varname">UPDATE_TARGET</code> instead to just
6765: set a specific target for each package to be
6766: installed during <span><strong class="command">make update</strong></span>
6767: (see above).</p></dd>
1.75 rillig 6768: </dl></div>
6769: </dd>
6770: <dt><span class="term">clean-update</span></dt>
6771: <dd>
1.88 wiz 6772: <p>Clean the source tree for all packages that would
6773: get updated if <span><strong class="command">make update</strong></span> was called
6774: from the current directory. This target should not be
6775: used if the current package (or any of its depending
6776: packages) have already been de-installed (e.g., after
6777: calling <span><strong class="command">make update</strong></span>) or you may lose
6778: some packages you intended to update. As a rule of
6779: thumb: only use this target <span class="emphasis"><em>before</em></span>
6780: the first time you run <span><strong class="command">make update</strong></span>
6781: and only if you have a dirty package tree (e.g., if you
6782: used <code class="varname">NOCLEAN</code>).</p>
6783: <p>If you are unsure about whether your tree is
6784: clean, you can either perform a <span><strong class="command">make
6785: clean</strong></span> at the top of the tree, or use the
6786: following sequence of commands from the directory of the
6787: package you want to update (<span class="emphasis"><em>before</em></span>
6788: running <span><strong class="command">make update</strong></span> for the first
6789: time, otherwise you lose all the packages you wanted to
6790: update!):</p>
1.87 wiz 6791: <pre class="screen">
6792: <code class="prompt">#</code> <strong class="userinput"><code>make clean-update</code></strong>
1.75 rillig 6793: <code class="prompt">#</code> <strong class="userinput"><code>make clean CLEANDEPENDS=YES</code></strong>
1.87 wiz 6794: <code class="prompt">#</code> <strong class="userinput"><code>make update</code></strong>
6795: </pre>
1.88 wiz 6796: <p>The following variables can be used either on the
6797: command line or in <code class="filename">/etc/mk.conf</code> to
6798: alter the behaviour of <span><strong class="command">make
6799: clean-update</strong></span>:</p>
1.75 rillig 6800: <div class="variablelist"><dl>
6801: <dt><span class="term"><code class="varname">CLEAR_DIRLIST</code></span></dt>
1.88 wiz 6802: <dd><p>After <span><strong class="command">make clean</strong></span>, do not
6803: reconstruct the list of directories to update for
6804: this package. Only use this if <span><strong class="command">make
6805: update</strong></span> successfully installed all
6806: packages you wanted to update. Normally, this is
6807: done automatically on <span><strong class="command">make
6808: update</strong></span>, but may have been suppressed by
6809: the <code class="varname">NOCLEAN</code> variable (see
6810: above).</p></dd>
1.75 rillig 6811: </dl></div>
6812: </dd>
1.88 wiz 6813: <dt><span class="term">replace</span></dt>
6814: <dd>
6815: <p>Update the installation of the current package. This
6816: differs from update in that it does not replace dependent
6817: packages. You will need to install <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgsrc/pkgtools/pkg_tarup/README.html" target="_top"><code class="filename">pkgsrc/pkgtools/pkg_tarup</code></a> for this
6818: target to work.</p>
6819: <p><span class="emphasis"><em>Be careful when using this
6820: target!</em></span> There are no guarantees that dependent
6821: packages will still work, in particular they will most
6822: certainly break if you <span><strong class="command">make replace</strong></span> a
6823: library package whose shared library major version changed
6824: between your installed version and the new one. For this
6825: reason, this target is not officially supported and only
6826: recommended for advanced users.</p>
6827: </dd>
1.75 rillig 6828: <dt><span class="term">info</span></dt>
6829: <dd><p>This target invokes <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_info+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_info</span>(1)</span></a> for the current
1.88 wiz 6830: package. You can use this to check which version of a
6831: package is installed.</p></dd>
6832: <dt><span class="term">index</span></dt>
6833: <dd>
6834: <p>This is a top-level command, i.e. it should be used in
6835: the <code class="filename">pkgsrc</code> directory. It creates a
6836: database of all packages in the local pkgsrc tree, including
6837: dependencies, comment, maintainer, and some other useful
6838: information. Individual entries are created by running
6839: <span><strong class="command">make describe</strong></span> in the packages'
6840: directories. This index file is saved as
6841: <code class="filename">pkgsrc/INDEX</code>. It can be displayed in
6842: verbose format by running <span><strong class="command">make
6843: print-index</strong></span>. You can search in it with
6844: <span><strong class="command">make search
6845: key=<em class="replaceable"><code>something</code></em></strong></span>. You can
6846: extract a list of all packages that depend on a particular
6847: one by running <span><strong class="command">make show-deps
6848: PKG=<em class="replaceable"><code>somepackage</code></em></strong></span>.</p>
6849: <p>Running this command takes a very long time, some
6850: hours even on fast machines!</p>
6851: </dd>
1.75 rillig 6852: <dt><span class="term">readme</span></dt>
1.88 wiz 6853: <dd>
6854: <p>This target generates a
6855: <code class="filename">README.html</code> file, which can be
6856: viewed using a browser such as <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a> or <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/www/links/README.html" target="_top"><code class="filename">www/links</code></a>. The generated files
6857: contain references to any packages which are in the
6858: <code class="varname">PACKAGES</code> directory on the local
6859: host. The generated files can be made to refer to URLs
6860: based on <code class="varname">FTP_PKG_URL_HOST</code> and
6861: <code class="varname">FTP_PKG_URL_DIR</code>. For example, if I
6862: wanted to generate <code class="filename">README.html</code>
6863: files which pointed to binary packages on the local
6864: machine, in the directory
6865: <code class="filename">/usr/packages</code>, set
6866: <code class="varname">FTP_PKG_URL_HOST=file://localhost</code> and
6867: <code class="varname">FTP_PKG_URL_DIR=/usr/packages</code>. The
6868: <code class="varname">${PACKAGES}</code> directory and its
6869: subdirectories will be searched for all the binary
6870: packages.</p>
6871: <p>The target can be run at the toplevel or in category
6872: directories, in which case it descends recursively.</p>
6873: </dd>
1.75 rillig 6874: <dt><span class="term">readme-all</span></dt>
1.88 wiz 6875: <dd><p>This is a top-level command, run it in
6876: <code class="filename">pkgsrc</code>. Use this target to create a
6877: file <code class="filename">README-all.html</code> which contains a
6878: list of all packages currently available in the NetBSD
6879: Packages Collection, together with the category they belong
6880: to and a short description. This file is compiled from the
6881: <code class="filename">pkgsrc/*/README.html</code> files, so be sure
6882: to run this <span class="emphasis"><em>after</em></span> a <span><strong class="command">make
6883: readme</strong></span>.</p></dd>
1.75 rillig 6884: <dt><span class="term">cdrom-readme</span></dt>
1.88 wiz 6885: <dd><p>This is very much the same as the
6886: “<span class="quote">readme</span>” target (see above), but is to be
6887: used when generating a pkgsrc tree to be written to a
6888: CD-ROM. This target also produces
6889: <code class="filename">README.html</code> files, and can be made
6890: to refer to URLs based on
6891: <code class="varname">CDROM_PKG_URL_HOST</code> and
1.87 wiz 6892: <code class="varname">CDROM_PKG_URL_DIR</code>.</p></dd>
1.75 rillig 6893: <dt><span class="term">show-distfiles</span></dt>
1.88 wiz 6894: <dd><p>This target shows which distfiles and patchfiles
6895: are needed to build the package
6896: (<code class="varname">ALLFILES</code>, which contains all
6897: <code class="varname">DISTFILES</code> and
1.87 wiz 6898: <code class="varname">PATCHFILES</code>, but not
6899: <code class="filename">patches/*</code>).</p></dd>
1.75 rillig 6900: <dt><span class="term">show-downlevel</span></dt>
1.88 wiz 6901: <dd><p>This target shows nothing if the package is not
6902: installed. If a version of this package is installed,
6903: but is not the version provided in this version of
6904: pkgsrc, then a warning message is displayed. This target
6905: can be used to show which of your installed packages are
6906: downlevel, and so the old versions can be deleted, and
6907: the current ones added.</p></dd>
1.75 rillig 6908: <dt><span class="term">show-pkgsrc-dir</span></dt>
1.88 wiz 6909: <dd><p>This target shows the directory in the pkgsrc
6910: hierarchy from which the package can be built and
6911: installed. This may not be the same directory as the one
6912: from which the package was installed. This target is
6913: intended to be used by people who may wish to upgrade
6914: many packages on a single host, and can be invoked from
6915: the top-level pkgsrc Makefile by using the
1.87 wiz 6916: “<span class="quote">show-host-specific-pkgs</span>” target.</p></dd>
1.75 rillig 6917: <dt><span class="term">show-installed-depends</span></dt>
1.88 wiz 6918: <dd><p>This target shows which installed packages match
6919: the current package's <code class="varname">DEPENDS</code>. Useful
6920: if out of date dependencies are causing build
6921: problems.</p></dd>
1.75 rillig 6922: <dt><span class="term">check-shlibs</span></dt>
1.88 wiz 6923: <dd><p>After a package is installed, check all its
6924: binaries and (on ELF platforms) shared libraries to see
6925: if they find the shared libs they need. Run by default
6926: if <code class="varname">PKG_DEVELOPER</code> is set in
1.87 wiz 6927: <code class="filename">/etc/mk.conf</code>.</p></dd>
1.75 rillig 6928: <dt><span class="term">print-PLIST</span></dt>
6929: <dd>
6930: <p>After a “<span class="quote">make install</span>” from a new or
1.88 wiz 6931: upgraded pkg, this prints out an attempt to generate a
6932: new <code class="filename">PLIST</code> from a <span><strong class="command">find
6933: -newer work/.extract_done</strong></span>. An attempt is made
6934: to care for shared libs etc., but it is
1.87 wiz 6935: <span class="emphasis"><em>strongly</em></span> recommended to review the
6936: result before putting it into
6937: <code class="filename">PLIST</code>. On upgrades, it's useful to
6938: diff the output of this command against an already
6939: existing <code class="filename">PLIST</code> file.</p>
1.88 wiz 6940: <p>If the package installs files via <a href="http://netbsd.gw.com/cgi-bin/man-cgi?tar+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span></a> or
6941: other methods that don't update file access times, be
6942: sure to add these files manually to your
1.87 wiz 6943: <code class="filename">PLIST</code>, as the “<span class="quote">find
6944: -newer</span>” command used by this target won't catch
6945: them!</p>
1.90 ! rillig 6946: <p>See <a href="#print-PLIST" title="12.3. Tweaking output of make print-PLIST">Section 12.3, “Tweaking output of <span><strong class="command">make print-PLIST</strong></span>”</a> for more
1.87 wiz 6947: information on this target.</p>
1.75 rillig 6948: </dd>
6949: <dt><span class="term">bulk-package</span></dt>
6950: <dd>
1.88 wiz 6951: <p>Used to do bulk builds. If an appropriate binary
6952: package already exists, no action is taken. If not, this
6953: target will compile, install and package it (and its
6954: depends, if <code class="varname">PKG_DEPENDS</code> is set
6955: properly. See <a href="#binary.configuration" title="6.3.1. Configuration">Section 6.3.1, “Configuration”</a>).
6956: After creating the binary package, the sources, the
6957: just-installed package and its required packages are
6958: removed, preserving free disk space.</p>
6959: <p><span class="emphasis"><em>Beware that this target may deinstall
6960: all packages installed on a system!</em></span></p>
1.75 rillig 6961: </dd>
6962: <dt><span class="term">bulk-install</span></dt>
6963: <dd>
1.88 wiz 6964: <p>Used during bulk-installs to install required
6965: packages. If an up-to-date binary package is available,
6966: it will be installed via <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>. If not,
6967: <span><strong class="command">make bulk-package</strong></span> will be executed,
1.87 wiz 6968: but the installed binary won't be removed.</p>
1.88 wiz 6969: <p>A binary package is considered
6970: “<span class="quote">up-to-date</span>” to be installed via
6971: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_add+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a> if:</p>
6972: <div class="itemizedlist"><ul type="disc">
6973: <li><p>None of the package's files
6974: (<code class="filename">Makefile</code>, ...) were modified
6975: since it was built.</p></li>
6976: <li><p>None of the package's required (binary)
6977: packages were modified since it was built.</p></li>
1.75 rillig 6978: </ul></div>
1.88 wiz 6979: <p><span class="emphasis"><em>Beware that this target may deinstall
6980: all packages installed on a system!</em></span></p>
1.75 rillig 6981: </dd>
6982: </dl></div>
6983: </div>
6984: </div>
6985: <div class="chapter" lang="en">
6986: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 6987: <a name="tools"></a>Chapter 17. Tools needed for building or running</h2></div></div></div>
1.75 rillig 6988: <div class="toc">
6989: <p><b>Table of Contents</b></p>
6990: <dl>
1.90 ! rillig 6991: <dt><span class="sect1"><a href="#pkgsrc-tools">17.1. Tools for pkgsrc builds</a></span></dt>
! 6992: <dt><span class="sect1"><a href="#package-tools">17.2. Tools needed by packages</a></span></dt>
! 6993: <dt><span class="sect1"><a href="#platform-tools">17.3. Tools provided by platforms</a></span></dt>
1.75 rillig 6994: </dl>
6995: </div>
1.87 wiz 6996: <p>The <code class="varname">USE_TOOLS</code> definition is used both internally
1.75 rillig 6997: by pkgsrc and also for individual packages to define what commands
6998: are needed for building a package (like <code class="varname">BUILD_DEPENDS</code>)
6999: or for later run-time of an installed packaged (such as
7000: <code class="varname">DEPENDS</code>).
7001: If the native system provides an adequate tool, then in many cases, a pkgsrc
1.87 wiz 7002: package will not be used.</p>
7003: <p>When building a package, the replacement tools are
1.75 rillig 7004: made available in a directory (as symlinks or wrapper scripts)
7005: that is early in the executable search path. Just like the buildlink
1.87 wiz 7006: system, this helps with consistent builds.</p>
7007: <p>A tool may be needed to help build a specific package. For example,
7008: perl, GNU make (gmake) or yacc may be needed.</p>
7009: <p>Also a tool may be needed, for example, because the native system's supplied
1.75 rillig 7010: tool may be inefficient for building a package with pkgsrc.
7011: For example, a package may need GNU awk, bison (instead of
1.87 wiz 7012: yacc) or a better sed.</p>
7013: <p>The tools used by a package can be listed by running
7014: <span><strong class="command">make show-tools</strong></span>.</p>
1.75 rillig 7015: <div class="sect1" lang="en">
7016: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 7017: <a name="pkgsrc-tools"></a>17.1. Tools for pkgsrc builds</h2></div></div></div>
1.87 wiz 7018: <p>The default set of tools used by pkgsrc is defined in
1.76 rillig 7019: <code class="filename">bsd.pkg.mk</code>. This includes standard Unix tools,
1.75 rillig 7020: such as: <span><strong class="command">cat</strong></span>, <span><strong class="command">awk</strong></span>,
7021: <span><strong class="command">chmod</strong></span>, <span><strong class="command">test</strong></span>, and so on.
7022: These can be seen by running:
1.87 wiz 7023: <span><strong class="command">make show-var VARNAME=USE_TOOLS</strong></span>.</p>
7024: <p>If a package needs a specific program to build
1.75 rillig 7025: then the <code class="varname">USE_TOOLS</code> variable can be used
1.87 wiz 7026: to define the tools needed.</p>
1.75 rillig 7027: </div>
7028: <div class="sect1" lang="en">
7029: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 7030: <a name="package-tools"></a>17.2. Tools needed by packages</h2></div></div></div>
1.87 wiz 7031: <p>In the following examples, the :pkgsrc means to use the pkgsrc version
1.75 rillig 7032: and not the native version for a build dependency.
7033: And the :run means that it is used for a
7034: run-time dependencies also (and becomes a DEPENDS).
7035: The default is a build dependency which can be set with
7036: :build. (So in this example, it is the same as gmake:build
1.87 wiz 7037: and pkg-config:build.)</p>
1.75 rillig 7038: <pre class="programlisting">
7039: USE_TOOLS+= mktemp:pkgsrc
7040: USE_TOOLS+= gmake perl:run pkg-config
7041: </pre>
1.87 wiz 7042: <p>When using the tools framework, a
1.75 rillig 7043: <code class="varname">TOOLS_PATH.foo</code> variable is defined
7044: which contains the full path to the appropriate tool. For example,
7045: <code class="varname">TOOLS_PATH.bash</code> could be “<span class="quote">/bin/bash</span>”
1.87 wiz 7046: on Linux systems.</p>
7047: <p>If you always need a pkgsrc version of the
1.75 rillig 7048: tool at run-time, then just use <code class="varname">DEPENDS</code> instead.
7049: </p>
7050: </div>
7051: <div class="sect1" lang="en">
7052: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 7053: <a name="platform-tools"></a>17.3. Tools provided by platforms</h2></div></div></div>
1.87 wiz 7054: <p>When improving or porting pkgsrc to a new platform, have a look
1.75 rillig 7055: at (or create) the corresponding platform specific make file fragment under
1.76 rillig 7056: <code class="filename">pkgsrc/mk/tools/tools.${OPSYS}.mk</code> which defines
1.75 rillig 7057: the name of the common tools. For example:</p>
7058: <pre class="programlisting">
7059: .if exists(/usr/bin/bzcat)
7060: TOOLS_PLATFORM.bzcat?= /usr/bin/bzcat
7061: .elif exists(/usr/bin/bzip2)
7062: TOOLS_PLATFORM.bzcat?= /usr/bin/bzip2 -cd
7063: .endif
1.69 rillig 7064:
1.75 rillig 7065: TOOLS_PLATFORM.true?= true # shell builtin
7066: </pre>
7067: </div>
7068: </div>
7069: <div class="chapter" lang="en">
7070: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 7071: <a name="fixes"></a>Chapter 18. Making your package work</h2></div></div></div>
1.75 rillig 7072: <div class="toc">
7073: <p><b>Table of Contents</b></p>
7074: <dl>
1.90 ! rillig 7075: <dt><span class="sect1"><a href="#general-operation">18.1. General operation</a></span></dt>
1.75 rillig 7076: <dd><dl>
1.90 ! rillig 7077: <dt><span class="sect2"><a href="#portability-of-packages">18.1.1. Portability of packages</a></span></dt>
! 7078: <dt><span class="sect2"><a href="#pulling-vars-from-etc-mk.conf">18.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></a></span></dt>
! 7079: <dt><span class="sect2"><a href="#user-interaction">18.1.3. User interaction</a></span></dt>
! 7080: <dt><span class="sect2"><a href="#handling-licenses">18.1.4. Handling licenses</a></span></dt>
! 7081: <dt><span class="sect2"><a href="#restricted-packages">18.1.5. Restricted packages</a></span></dt>
! 7082: <dt><span class="sect2"><a href="#dependencies">18.1.6. Handling dependencies</a></span></dt>
! 7083: <dt><span class="sect2"><a href="#conflicts">18.1.7. Handling conflicts with other packages</a></span></dt>
! 7084: <dt><span class="sect2"><a href="#not-building-packages">18.1.8. Packages that cannot or should not be built</a></span></dt>
! 7085: <dt><span class="sect2"><a href="#undeletable-packages">18.1.9. Packages which should not be deleted, once installed</a></span></dt>
! 7086: <dt><span class="sect2"><a href="#security-handling">18.1.10. Handling packages with security problems</a></span></dt>
! 7087: <dt><span class="sect2"><a href="#bumping-pkgrevision">18.1.11. How to handle incrementing versions when fixing an existing package</a></span></dt>
! 7088: <dt><span class="sect2"><a href="#fixes.subst">18.1.12. Substituting variable text in the package files (the SUBST framework)</a></span></dt>
! 7089: </dl></dd>
! 7090: <dt><span class="sect1"><a href="#fixes.fetch">18.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</a></span></dt>
! 7091: <dd><dl>
! 7092: <dt><span class="sect2"><a href="#no-plain-download">18.2.1. Packages whose distfiles aren't available for plain downloading</a></span></dt>
! 7093: <dt><span class="sect2"><a href="#modified-distfiles-same-name">18.2.2. How to handle modified distfiles with the 'old' name</a></span></dt>
! 7094: </dl></dd>
! 7095: <dt><span class="sect1"><a href="#fixes.configure">18.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
! 7096: <dd><dl>
! 7097: <dt><span class="sect2"><a href="#fixes.libtool">18.3.1. Shared libraries - libtool</a></span></dt>
! 7098: <dt><span class="sect2"><a href="#using-libtool">18.3.2. Using libtool on GNU packages that already support libtool</a></span></dt>
! 7099: <dt><span class="sect2"><a href="#autoconf-automake">18.3.3. GNU Autoconf/Automake</a></span></dt>
! 7100: </dl></dd>
! 7101: <dt><span class="sect1"><a href="#programming-languages">18.4. Programming languages</a></span></dt>
! 7102: <dd><dl>
! 7103: <dt><span class="sect2"><a href="#basic-programming-languages">18.4.1. C, C++, and Fortran</a></span></dt>
! 7104: <dt><span class="sect2"><a href="#java-programming-language">18.4.2. Java</a></span></dt>
! 7105: <dt><span class="sect2"><a href="#perl-scripts">18.4.3. Packages containing perl scripts</a></span></dt>
! 7106: <dt><span class="sect2"><a href="#other-programming-languages">18.4.4. Other programming languages</a></span></dt>
! 7107: </dl></dd>
! 7108: <dt><span class="sect1"><a href="#fixes.build">18.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</a></span></dt>
! 7109: <dd><dl>
! 7110: <dt><span class="sect2"><a href="#fixes.build.cpp">18.5.1. Compiling C and C++ code conditionally</a></span></dt>
! 7111: <dt><span class="sect2"><a href="#compiler-bugs">18.5.2. How to handle compiler bugs</a></span></dt>
! 7112: <dt><span class="sect2"><a href="#undefined-reference">18.5.3. Undefined reference to “<span class="quote">...</span>”</a></span></dt>
! 7113: <dt><span class="sect2"><a href="#out-of-memory">18.5.4. Running out of memory</a></span></dt>
! 7114: </dl></dd>
! 7115: <dt><span class="sect1"><a href="#fixes.install">18.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</a></span></dt>
! 7116: <dd><dl>
! 7117: <dt><span class="sect2"><a href="#install-scripts">18.6.1. Creating needed directories</a></span></dt>
! 7118: <dt><span class="sect2"><a href="#where-to-install-documentation">18.6.2. Where to install documentation</a></span></dt>
! 7119: <dt><span class="sect2"><a href="#installing-score-files">18.6.3. Installing score files</a></span></dt>
! 7120: <dt><span class="sect2"><a href="#hardcoded-paths">18.6.4. Packages with hardcoded paths to other interpreters</a></span></dt>
! 7121: <dt><span class="sect2"><a href="#perl-modules">18.6.5. Packages installing perl modules</a></span></dt>
! 7122: <dt><span class="sect2"><a href="#faq.info-files">18.6.6. Packages installing info files</a></span></dt>
! 7123: <dt><span class="sect2"><a href="#manpages">18.6.7. Packages installing man pages</a></span></dt>
! 7124: <dt><span class="sect2"><a href="#gconf2-data-files">18.6.8. Packages installing GConf2 data files</a></span></dt>
! 7125: <dt><span class="sect2"><a href="#scrollkeeper-data-files">18.6.9. Packages installing scrollkeeper data files</a></span></dt>
! 7126: <dt><span class="sect2"><a href="#x11-fonts">18.6.10. Packages installing X11 fonts</a></span></dt>
! 7127: <dt><span class="sect2"><a href="#gtk2-modules">18.6.11. Packages installing GTK2 modules</a></span></dt>
! 7128: <dt><span class="sect2"><a href="#sgml-xml-data">18.6.12. Packages installing SGML or XML data</a></span></dt>
! 7129: <dt><span class="sect2"><a href="#mime-database">18.6.13. Packages installing extensions to the MIME database</a></span></dt>
! 7130: <dt><span class="sect2"><a href="#intltool">18.6.14. Packages using intltool</a></span></dt>
! 7131: <dt><span class="sect2"><a href="#startup-scripts">18.6.15. Packages installing startup scripts</a></span></dt>
! 7132: <dt><span class="sect2"><a href="#tex-packages">18.6.16. Packages installing TeX modules</a></span></dt>
! 7133: <dt><span class="sect2"><a href="#emulation-packages">18.6.17. Packages supporting running binaries in
1.87 wiz 7134: emulation</a></span></dt>
1.90 ! rillig 7135: <dt><span class="sect2"><a href="#hicolor-theme">18.6.18. Packages installing hicolor theme icons</a></span></dt>
! 7136: <dt><span class="sect2"><a href="#desktop-files">18.6.19. Packages installing desktop files</a></span></dt>
1.75 rillig 7137: </dl></dd>
1.90 ! rillig 7138: <dt><span class="sect1"><a href="#punting">18.7. Marking packages as having problems</a></span></dt>
1.75 rillig 7139: </dl>
7140: </div>
7141: <div class="sect1" lang="en">
7142: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 7143: <a name="general-operation"></a>18.1. General operation</h2></div></div></div>
1.75 rillig 7144: <div class="sect2" lang="en">
7145: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7146: <a name="portability-of-packages"></a>18.1.1. Portability of packages</h3></div></div></div>
1.78 rillig 7147: <p>One appealing feature of pkgsrc is that it runs on many
1.87 wiz 7148: different platforms. As a result, it is important to ensure,
7149: where possible, that packages in pkgsrc are portable. This
7150: chapter mentions some particular details you should pay
7151: attention to while working on pkgsrc.</p>
1.78 rillig 7152: </div>
7153: <div class="sect2" lang="en">
7154: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7155: <a name="pulling-vars-from-etc-mk.conf"></a>18.1.2. How to pull in user-settable variables from <code class="filename">mk.conf</code></h3></div></div></div>
1.78 rillig 7156: <p>The pkgsrc user can configure pkgsrc by overriding several
1.87 wiz 7157: variables in the file pointed to by <code class="varname">MAKECONF</code>,
7158: which is <code class="filename">/etc/mk.conf</code> by default. When you
7159: want to use those variables in the preprocessor directives of
7160: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> (for example <code class="literal">.if</code> or
7161: <code class="literal">.for</code>), you need to include the file
7162: <code class="filename">../../mk/bsd.prefs.mk</code> before, which in turn
7163: loads the user preferences.</p>
1.78 rillig 7164: <p>But note that some variables may not be completely defined
1.87 wiz 7165: after <code class="filename">../../mk/bsd.prefs.mk</code> has been
7166: included, as they may contain references to variables that are
7167: not yet defined. In shell commands this is no problem, since
7168: variables are actually macros, which are only expanded when they
7169: are used. But in the preprocessor directives mentioned above and
7170: in dependency lines (of the form <code class="literal">target:
7171: dependencies</code>) the variables are expanded at load
7172: time.</p>
1.78 rillig 7173: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
7174: <h3 class="title">Note</h3>
7175: <p>Currently there is no exhaustive list of all
1.87 wiz 7176: variables that tells you whether they can be used at load time
7177: or only at run time, but it is in preparation.</p>
1.78 rillig 7178: </div>
7179: </div>
7180: <div class="sect2" lang="en">
7181: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7182: <a name="user-interaction"></a>18.1.3. User interaction</h3></div></div></div>
1.88 wiz 7183: <p>Occasionally, packages require interaction from the user,
7184: and this can be in a number of ways:</p>
1.78 rillig 7185: <div class="itemizedlist"><ul type="disc">
1.79 rillig 7186: <li><p>When fetching the distfiles, some packages require user
1.87 wiz 7187: interaction such as entering username/password or accepting a
7188: license on a web page.</p></li>
1.88 wiz 7189: <li><p>When extracting the distfiles, some packages may ask for
7190: passwords.</p></li>
1.78 rillig 7191: <li><p>help to configure the package before it is built</p></li>
7192: <li><p>help during the build process</p></li>
7193: <li><p>help during the installation of a package</p></li>
7194: </ul></div>
1.88 wiz 7195: <p>The <code class="varname">INTERACTIVE_STAGE</code> definition is
7196: provided to notify the pkgsrc mechanism of an interactive stage
7197: which will be needed, and this should be set in the package's
7198: <code class="filename">Makefile</code>, e.g.:</p>
1.75 rillig 7199: <pre class="programlisting">
1.87 wiz 7200: INTERACTIVE_STAGE= build
7201: </pre>
1.78 rillig 7202: <p>Multiple interactive stages can be specified:</p>
1.75 rillig 7203: <pre class="programlisting">
1.87 wiz 7204: INTERACTIVE_STAGE= configure install
7205: </pre>
1.88 wiz 7206: <p>The user can then decide to skip this package by setting the
7207: <code class="varname">BATCH</code> variable.</p>
1.75 rillig 7208: </div>
7209: <div class="sect2" lang="en">
7210: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7211: <a name="handling-licenses"></a>18.1.4. Handling licenses</h3></div></div></div>
1.78 rillig 7212: <p>A package may be covered by a license which the user has
1.87 wiz 7213: or has not agreed to accept. For these cases, pkgsrc contains
7214: a mechanism to note that a package is covered by a particular
7215: license, and the package cannot be built unless the user has
7216: accepted the license. (Installation of binary packages are
7217: not currently subject to this mechanism.) Packages with
7218: licenses that are either Open Source according to the Open
7219: Source Initiative or Free according to the Free Software
7220: Foundation will not be marked with a license tag. Packages
7221: with licenses that have not been determined to meet either
7222: definition will be marked with a license tag referring to the
7223: license. This will prevent building unless pkgsrc is informed
7224: that the license is acceptable, and enables displaying the
7225: license.</p>
1.78 rillig 7226: <p>The license tag mechanism is intended to address
1.87 wiz 7227: copyright-related issues surrounding building, installing and
7228: using a package, and not to address redistribution issues (see
7229: <code class="varname">RESTRICTED</code> and
7230: <code class="varname">NO_SRC_ON_FTP</code>, etc.). However, the above
7231: definition of licenses for which tags are not needed implies
7232: that packages with redistribution restrictions should have
7233: tags.</p>
7234: <p>Denoting that a package is covered by a particular license
7235: is done by placing the license in
7236: <code class="filename">pkgsrc/licenses</code> and setting the
7237: <code class="varname">LICENSE</code> variable to a string identifying the
7238: license, e.g. in <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/xv/README.html" target="_top"><code class="filename">graphics/xv</code></a>:</p>
7239: <pre class="programlisting">
7240: LICENSE= xv-license
7241: </pre>
7242: <p>When trying to build, the user will get a notice that the
7243: package is covered by a license which has not been
7244: accepted:</p>
7245: <pre class="programlisting">
7246: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
7247: ===> xv-3.10anb9 has an unacceptable license: xv-license.
7248: ===> To view the license, enter "/usr/bin/make show-license".
7249: ===> To indicate acceptance, add this line to your /etc/mk.conf:
7250: ===> ACCEPTABLE_LICENSES+=xv-license
7251: *** Error code 1
7252: </pre>
1.78 rillig 7253: <p>The license can be viewed with <span><strong class="command">make
1.87 wiz 7254: show-license</strong></span>, and if it is considered appropriate,
7255: the line printed above can be added to
7256: <code class="filename">/etc/mk.conf</code> to indicate acceptance of
7257: the particular license:</p>
1.78 rillig 7258: <pre class="programlisting">
1.87 wiz 7259: ACCEPTABLE_LICENSES+=xv-license
7260: </pre>
1.78 rillig 7261: <p>When adding a package with a new license, the license
1.87 wiz 7262: text should be added to <code class="filename">pkgsrc/licenses</code>
7263: for displaying. A list of known licenses can be seen in this
7264: directory as well as by looking at the list of (commented
7265: out) <code class="varname">ACCEPTABLE_LICENSES</code> variable
7266: settings in
7267: <code class="filename">pkgsrc/mk/defaults/mk.conf</code>.</p>
1.78 rillig 7268: <p>The use of <code class="varname">LICENSE=shareware</code>,
1.87 wiz 7269: <code class="varname">LICENSE=no-commercial-use</code>, and similar
7270: language is deprecated because it does not crisply refer to
7271: a particular license text. Another problem with such usage
7272: is that it does not enable a user to denote acceptance of
7273: the license for a single package without accepting the same
7274: license text for another package. In particular, this can
7275: be inappropriate when e.g. one accepts a particular license to
7276: indicate to pkgsrc that a fee has been paid.</p>
1.75 rillig 7277: </div>
7278: <div class="sect2" lang="en">
7279: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7280: <a name="restricted-packages"></a>18.1.5. Restricted packages</h3></div></div></div>
1.75 rillig 7281: <p>Some licenses restrict how software may be re-distributed.
1.87 wiz 7282: In order to satisfy these restrictions, the package system
7283: defines five make variables that can be set to note these
7284: restrictions:</p>
1.75 rillig 7285: <div class="itemizedlist"><ul type="disc">
7286: <li>
7287: <p><code class="varname">RESTRICTED</code></p>
7288: <p>This variable should be set whenever a restriction
1.87 wiz 7289: exists (regardless of its kind). Set this variable to a
7290: string containing the reason for the restriction.</p>
1.75 rillig 7291: </li>
7292: <li>
7293: <p><code class="varname">NO_BIN_ON_CDROM</code></p>
7294: <p>Binaries may not be placed on CD-ROM. Set this
1.87 wiz 7295: variable to <code class="varname">${RESTRICTED}</code> whenever a
7296: binary package may not be included on a CD-ROM.</p>
1.75 rillig 7297: </li>
7298: <li>
7299: <p><code class="varname">NO_BIN_ON_FTP</code></p>
7300: <p>Binaries may not be placed on an FTP server. Set
1.87 wiz 7301: this variable to <code class="varname">${RESTRICTED}</code>
7302: whenever a binary package may not not be made available
7303: on the Internet.</p>
1.75 rillig 7304: </li>
7305: <li>
7306: <p><code class="varname">NO_SRC_ON_CDROM</code></p>
7307: <p>Distfiles may not be placed on CD-ROM. Set this
1.87 wiz 7308: variable to <code class="varname">${RESTRICTED}</code> if
7309: re-distribution of the source code or other distfile(s) is
7310: not allowed on CD-ROMs.</p>
1.75 rillig 7311: </li>
7312: <li>
7313: <p><code class="varname">NO_SRC_ON_FTP</code></p>
7314: <p>Distfiles may not be placed on FTP. Set this variable
1.87 wiz 7315: to <code class="varname">${RESTRICTED}</code> if re-distribution of
7316: the source code or other distfile(s) via the Internet is not
7317: allowed. If this variable is not set, the distfile(s) will
7318: be mirrored on ftp.NetBSD.org.</p>
1.75 rillig 7319: </li>
7320: </ul></div>
7321: <p>Please note that the use of <code class="varname">NO_PACKAGE</code>,
1.87 wiz 7322: <code class="varname">IGNORE</code>, <code class="varname">NO_CDROM</code>, or other
7323: generic make variables to denote restrictions is deprecated,
7324: because they unconditionally prevent users from generating
7325: binary packages!</p>
1.75 rillig 7326: </div>
7327: <div class="sect2" lang="en">
7328: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7329: <a name="dependencies"></a>18.1.6. Handling dependencies</h3></div></div></div>
1.75 rillig 7330: <p>Your package may depend on some other package being present
1.88 wiz 7331: - and there are various ways of expressing this dependency.
7332: pkgsrc supports the <code class="varname">BUILD_DEPENDS</code> and
7333: <code class="varname">DEPENDS</code> definitions, the
7334: <code class="varname">USE_TOOLS</code> definition, as well as dependencies
7335: via <code class="filename">buildlink3.mk</code>, which is the preferred way
7336: to handle dependencies, and which uses the variables named above.
1.90 ! rillig 7337: See <a href="#buildlink" title="Chapter 13. Buildlink methodology">Chapter 13, <i>Buildlink methodology</i></a> for more information.</p>
1.75 rillig 7338: <p>The basic difference between the two variables is as
1.87 wiz 7339: follows: The <code class="varname">DEPENDS</code> definition registers
7340: that pre-requisite in the binary package so it will be pulled in
7341: when the binary package is later installed, whilst the
7342: <code class="varname">BUILD_DEPENDS</code> definition does not, marking a
7343: dependency that is only needed for building the package.</p>
1.75 rillig 7344: <p>This means that if you only need a package present whilst
1.87 wiz 7345: you are building, it should be noted as a
7346: <code class="varname">BUILD_DEPENDS</code>.</p>
1.75 rillig 7347: <p>The format for a <code class="varname">BUILD_DEPENDS</code> and a
1.87 wiz 7348: <code class="varname">DEPENDS</code> definition is:</p>
1.75 rillig 7349: <pre class="programlisting">
1.87 wiz 7350: <pre-req-package-name>:../../<category>/<pre-req-package>
7351: </pre>
1.75 rillig 7352: <p>Please note that the “<span class="quote">pre-req-package-name</span>”
1.87 wiz 7353: may include any of the wildcard version numbers recognized by
7354: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_info+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_info</span>(1)</span></a>.</p>
1.75 rillig 7355: <div class="orderedlist"><ol type="1">
7356: <li>
7357: <p>If your package needs another package's binaries or
1.87 wiz 7358: libraries to build or run, and if that package has a
7359: <code class="filename">buildlink3.mk</code> file available, use it:</p>
1.75 rillig 7360: <pre class="programlisting">
1.87 wiz 7361: .include "../../graphics/jpeg/buildlink3.mk"
7362: </pre>
1.75 rillig 7363: </li>
7364: <li>
7365: <p>If your package needs to use another package to build
1.87 wiz 7366: itself and there is no <code class="filename">buildlink3.mk</code>
7367: file available, use the <code class="varname">BUILD_DEPENDS</code>
7368: definition:</p>
1.75 rillig 7369: <pre class="programlisting">
1.87 wiz 7370: BUILD_DEPENDS+= autoconf-2.13:../../devel/autoconf
7371: </pre>
1.75 rillig 7372: </li>
7373: <li>
7374: <p>If your package needs a library with which to link and
1.76 rillig 7375: again there is no <code class="filename">buildlink3.mk</code> file
1.87 wiz 7376: available, this is specified using the
7377: <code class="varname">DEPENDS</code> definition. For example:</p>
1.75 rillig 7378: <pre class="programlisting">
1.87 wiz 7379: DEPENDS+= xpm-3.4j:../../graphics/xpm
7380: </pre>
1.75 rillig 7381: <p>You can also use wildcards in package dependences:</p>
7382: <pre class="programlisting">
1.87 wiz 7383: DEPENDS+= xpm-[0-9]*:../../graphics/xpm
7384: </pre>
1.75 rillig 7385: <p>Note that such wildcard dependencies are retained when
1.87 wiz 7386: creating binary packages. The dependency is checked when
7387: installing the binary package and any package which matches
7388: the pattern will be used. Wildcard dependencies should be
7389: used with care.</p>
1.75 rillig 7390: <p>The “<span class="quote">-[0-9]*</span>” should be used instead of
1.87 wiz 7391: “<span class="quote">-*</span>” to avoid potentially ambiguous matches
7392: such as “<span class="quote">tk-postgresql</span>” matching a
7393: “<span class="quote">tk-*</span>” <code class="varname">DEPENDS</code>.</p>
1.75 rillig 7394: <p>Wildcards can also be used to specify that a package
1.87 wiz 7395: will only build against a certain minimum version of a
7396: pre-requisite:</p>
1.75 rillig 7397: <pre class="programlisting">
1.87 wiz 7398: DEPENDS+= tiff>=3.5.4:../../graphics/tiff
7399: </pre>
1.75 rillig 7400: <p>This means that the package will build against version
1.87 wiz 7401: 3.5.4 of the tiff library or newer. Such a dependency may
7402: be warranted if, for example, the API of the library has
7403: changed with version 3.5.4 and a package would not compile
7404: against an earlier version of tiff.</p>
1.75 rillig 7405: <p>Please note that such dependencies should only be
1.87 wiz 7406: updated if a package requires a newer pre-requisite, but
7407: not to denote recommendations such as
7408: ABI changes that do not prevent a package from building
7409: correctly. Such recommendations can be expressed using
7410: <code class="varname">ABI_DEPENDS</code>:</p>
1.75 rillig 7411: <pre class="programlisting">
1.87 wiz 7412: ABI_DEPENDS+= tiff>=3.6.1:../../graphics/tiff
7413: </pre>
1.75 rillig 7414: <p>In addition to the above <code class="varname">DEPENDS</code>
1.87 wiz 7415: line, this denotes that while a package will build against
7416: tiff>=3.5.4, at least version 3.6.1 is recommended.
7417: <code class="varname">ABI_DEPENDS</code> entries will be turned into
7418: dependencies unless explicitly ignored (in which case a
7419: warning will be printed).</p>
1.75 rillig 7420: <p>To ignore these ABI dependency recommendations and just
1.87 wiz 7421: use the required <code class="varname">DEPENDS</code>, set
7422: <code class="varname">USE_ABI_DEPENDS=NO</code>. This may make
7423: it easier and faster to update packages built using pkgsrc,
7424: since older compatible dependencies can continue to be
7425: used. This is useful for people who watch their rebuilds
7426: very carefully; it is not very good as a general-purpose
7427: hammer. If you use it, you need to be mindful of possible
7428: ABI changes, including those from the underlying OS.</p>
1.75 rillig 7429: <p>Packages that are built with recommendations ignored
1.87 wiz 7430: may not be uploaded to ftp.NetBSD.org by developers and
7431: should not be used across different systems that may have
7432: different versions of binary packages installed.</p>
1.75 rillig 7433: <p>For security fixes, please update the package
1.90 ! rillig 7434: vulnerabilities file. See <a href="#security-handling" title="18.1.10. Handling packages with security problems">Section 18.1.10, “Handling packages with security problems”</a> for more
1.87 wiz 7435: information.</p>
1.75 rillig 7436: </li>
7437: <li>
7438: <p>If your package needs some executable to be able to run
1.87 wiz 7439: correctly and if there's no
7440: <code class="filename">buildlink3.mk</code> file, this is specified
7441: using the <code class="varname">DEPENDS</code> variable. The
7442: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/print/lyx/README.html" target="_top"><code class="filename">print/lyx</code></a> package needs to
7443: be able to execute the latex binary from the teTeX package
7444: when it runs, and that is specified:</p>
1.75 rillig 7445: <pre class="programlisting">
1.87 wiz 7446: DEPENDS+= teTeX-[0-9]*:../../print/teTeX
7447: </pre>
1.75 rillig 7448: <p>The comment about wildcard dependencies from previous
1.87 wiz 7449: paragraph applies here, too.</p>
1.75 rillig 7450: </li>
7451: </ol></div>
7452: <p>If your package needs files from another package to build,
1.87 wiz 7453: add the relevant distribution files to
7454: <code class="varname">DISTFILES</code>, so they will be extracted
7455: automatically. See the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/print/ghostscript/README.html" target="_top"><code class="filename">print/ghostscript</code></a> package for an example.
7456: (It relies on the jpeg sources being present in source form
7457: during the build.)</p>
1.88 wiz 7458: <p>Please also note the
7459: <code class="varname">BUILD_USES_GETTEXT_M4</code> definition, which is
7460: provided as convenience definition. It adds a build dependency on
7461: either an installed version of an older gettext package, or if it
7462: isn't, installs the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/gettext-m4/README.html" target="_top"><code class="filename">devel/gettext-m4</code></a> package.</p>
1.75 rillig 7463: </div>
7464: <div class="sect2" lang="en">
7465: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7466: <a name="conflicts"></a>18.1.7. Handling conflicts with other packages</h3></div></div></div>
1.75 rillig 7467: <p>Your package may conflict with other packages a user might
1.87 wiz 7468: already have installed on his system, e.g. if your package
1.88 wiz 7469: installs the same set of files as another package in the pkgsrc
7470: tree.</p>
1.75 rillig 7471: <p>In this case you can set <code class="varname">CONFLICTS</code> to a
1.87 wiz 7472: space-separated list of packages (including version string) your
7473: package conflicts with.</p>
1.76 rillig 7474: <p>For example, <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/Xaw3d/README.html" target="_top"><code class="filename">x11/Xaw3d</code></a>
1.87 wiz 7475: and <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/x11/Xaw-Xpm/README.html" target="_top"><code class="filename">x11/Xaw-Xpm</code></a>
7476: install the same shared library, thus you set in
7477: <code class="filename">pkgsrc/x11/Xaw3d/Makefile</code>:</p>
7478: <pre class="programlisting">
7479: CONFLICTS= Xaw-Xpm-[0-9]*
7480: </pre>
7481: <p>and in <code class="filename">pkgsrc/x11/Xaw-Xpm/Makefile</code>:</p>
1.75 rillig 7482: <pre class="programlisting">
1.87 wiz 7483: CONFLICTS= Xaw3d-[0-9]*
7484: </pre>
1.75 rillig 7485: <p>Packages will automatically conflict with other packages
1.87 wiz 7486: with the name prefix and a different version
7487: string. “<span class="quote">Xaw3d-1.5</span>” e.g. will automatically
7488: conflict with the older version “<span class="quote">Xaw3d-1.3</span>”.</p>
1.75 rillig 7489: </div>
7490: <div class="sect2" lang="en">
7491: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7492: <a name="not-building-packages"></a>18.1.8. Packages that cannot or should not be built</h3></div></div></div>
1.75 rillig 7493: <p>There are several reasons why a package might be
1.88 wiz 7494: instructed to not build under certain circumstances. If the
1.87 wiz 7495: package builds and runs on most platforms, the exceptions
7496: should be noted with <code class="varname">NOT_FOR_PLATFORM</code>. If
7497: the package builds and runs on a small handful of platforms,
7498: set <code class="varname">ONLY_FOR_PLATFORM</code> instead.
7499: Both <code class="varname">ONLY_FOR_PLATFORM</code> and
7500: <code class="varname">NOT_FOR_PLATFORM</code> are OS triples
7501: (OS-version-platform) that can use glob-style
7502: wildcards.</p>
1.88 wiz 7503: <p>Some packages are tightly bound to a specific version of an
7504: operating system, e.g. LKMs or <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/sysutils/lsof/README.html" target="_top"><code class="filename">sysutils/lsof</code></a>. Such binary packages are not
7505: backwards compatible with other versions of the OS, and should be
7506: uploaded to a version specific directory on the FTP server. Mark
7507: these packages by setting <code class="varname">OSVERSION_SPECIFIC</code> to
7508: “<span class="quote">yes</span>”. This variable is not currently used by any of
7509: the package system internals, but may be used in the
7510: future.</p>
1.75 rillig 7511: <p>If the package should be skipped (for example, because it
1.87 wiz 7512: provides functionality already provided by the system), set
1.88 wiz 7513: <code class="varname">PKG_SKIP_REASON</code> to a descriptive message. If
7514: the package should fail because some preconditions are not met,
7515: set <code class="varname">PKG_FAIL_REASON</code> to a descriptive
1.87 wiz 7516: message.</p>
1.75 rillig 7517: </div>
7518: <div class="sect2" lang="en">
7519: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7520: <a name="undeletable-packages"></a>18.1.9. Packages which should not be deleted, once installed</h3></div></div></div>
1.75 rillig 7521: <p>To ensure that a package may not be deleted, once it has been
1.87 wiz 7522: installed, the <code class="varname">PKG_PRESERVE</code> definition should
7523: be set in the package Makefile. This will be carried into any
7524: binary package that is made from this pkgsrc entry. A
7525: “<span class="quote">preserved</span>” package will
7526: not be deleted using <a href="http://netbsd.gw.com/cgi-bin/man-cgi?pkg_delete+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">pkg_delete</span>(1)</span></a> unless the
7527: “<span class="quote">-f</span>” option is used.</p>
1.75 rillig 7528: </div>
7529: <div class="sect2" lang="en">
7530: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7531: <a name="security-handling"></a>18.1.10. Handling packages with security problems</h3></div></div></div>
1.75 rillig 7532: <p>When a vulnerability is found, this should be noted in
1.87 wiz 7533: <code class="filename">localsrc/security/advisories/pkg-vulnerabilities</code>,
7534: and after committing that file, use <span><strong class="command">make upload</strong></span>
7535: in the same directory to update the file on ftp.NetBSD.org.</p>
1.75 rillig 7536: <p>After fixing the vulnerability by a patch, its
1.87 wiz 7537: <code class="varname">PKGREVISION</code> should be increased (this
7538: is of course not necessary if the problem is fixed by using
7539: a newer release of the software).</p>
1.75 rillig 7540: <p>Also, if the fix should be applied to the stable pkgsrc
1.87 wiz 7541: branch, be sure to submit a pullup request!</p>
1.75 rillig 7542: <p>Binary packages already on ftp.NetBSD.org will be handled
1.87 wiz 7543: semi-automatically by a weekly cron job.</p>
1.75 rillig 7544: </div>
7545: <div class="sect2" lang="en">
7546: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7547: <a name="bumping-pkgrevision"></a>18.1.11. How to handle incrementing versions when fixing an existing package</h3></div></div></div>
1.75 rillig 7548: <p>When making fixes to an existing package it can be useful
1.87 wiz 7549: to change the version number in <code class="varname">PKGNAME</code>. To
7550: avoid conflicting with future versions by the original author, a
7551: “<span class="quote">nb1</span>”, “<span class="quote">nb2</span>”, ... suffix can be used
7552: on package versions by setting <code class="varname">PKGREVISION=1</code>
7553: (2, ...). The “<span class="quote">nb</span>” is treated like a
7554: “<span class="quote">.</span>” by the package tools. e.g.</p>
7555: <pre class="programlisting">
7556: DISTNAME= foo-17.42
7557: PKGREVISION= 9
7558: </pre>
1.75 rillig 7559: <p>will result in a <code class="varname">PKGNAME</code> of
1.87 wiz 7560: “<span class="quote">foo-17.42nb9</span>”. If you want to use the original
7561: value of <code class="varname">PKGNAME</code> without the “<span class="quote">nbX</span>”
7562: suffix, e.g. for setting <code class="varname">DIST_SUBDIR</code>, use
7563: <code class="varname">PKGNAME_NOREV</code>.</p>
1.75 rillig 7564: <p>When a new release of the package is released, the
1.87 wiz 7565: <code class="varname">PKGREVISION</code> should be removed, e.g. on a new
7566: minor release of the above package, things should be like:</p>
1.75 rillig 7567: <pre class="programlisting">
1.87 wiz 7568: DISTNAME= foo-17.43
7569: </pre>
7570: <p><code class="varname">PKGREVISION</code> should be incremented for any
7571: non-trivial change in the resulting binary package. Without a
7572: <code class="varname">PKGREVISION</code> bump, someone with the previous
7573: version installed has no way of knowing that their package is out
7574: of date. Thus, changes without increasing
7575: <code class="varname">PKGREVISION</code> are essentially labeled "this is so
7576: trivial that no reasonable person would want to upgrade", and this
7577: is the rough test for when increasing
7578: <code class="varname">PKGREVISION</code> is appropriate. Examples of
7579: changes that do not merit increasing
7580: <code class="varname">PKGREVISION</code> are:</p>
7581: <pre class="programlisting">
7582: Changing <code class="varname">HOMEPAGE</code>, <code class="varname">MAINTAINER</code>,
7583: or comments in Makefile.
7584: Changing build variables if the resulting binary package is the same.
7585: Changing <code class="filename">DESCR</code>.
7586: Adding <code class="varname">PKG_OPTIONS</code> if the default options don't change.
7587: </pre>
7588: <p>Examples of changes that do merit an increase to
7589: <code class="varname">PKGREVISION</code> include:</p>
7590: <pre class="programlisting">
7591: Security fixes
7592: Changes or additions to a patch file
7593: Changes to the <code class="filename">PLIST</code>
7594: </pre>
1.78 rillig 7595: <p>PKGREVISION must also be incremented when dependencies have ABI
7596: changes.</p>
1.75 rillig 7597: </div>
1.79 rillig 7598: <div class="sect2" lang="en">
7599: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7600: <a name="fixes.subst"></a>18.1.12. Substituting variable text in the package files (the SUBST framework)</h3></div></div></div>
1.79 rillig 7601: <p>When you want to replace the same text in multiple files
1.87 wiz 7602: or when the replacement text varies, patches alone cannot help.
7603: This is where the SUBST framework comes in. It provides an
7604: easy-to-use interface for replacing text in files.
7605: Example:</p>
7606: <pre class="programlisting">
7607: SUBST_CLASSES+= fix-paths
7608: SUBST_STAGE.fix-paths= pre-configure
7609: SUBST_MESSAGE.fix-paths= Fixing absolute paths.
7610: SUBST_FILES.fix-paths= src/*.c
7611: SUBST_FILES.fix-paths+= scripts/*.sh
7612: SUBST_SED.fix-paths= -e 's,"/usr/local,"${PREFIX},g'
7613: SUBST_SED.fix-paths+= -e 's,"/var/log,"${VARBASE}/log,g'
7614: </pre>
1.79 rillig 7615: <p><code class="varname">SUBST_CLASSES</code> is a list of identifiers
1.87 wiz 7616: that are used to identify the different SUBST blocks that are
7617: defined. The SUBST framework is heavily used by pkgsrc, so it is
7618: important to always use the <code class="literal">+=</code> operator with
7619: this variable. Otherwise some substitutions may be
7620: skipped.</p>
1.79 rillig 7621: <p>The remaining variables of each SUBST block are
1.87 wiz 7622: parameterized with the identifier from the first line
7623: (<code class="literal">fix-paths</code> in this case.) They can be seen as
7624: parameters to a function call.</p>
1.79 rillig 7625: <p><code class="varname">SUBST_STAGE.*</code> specifies the stage at
1.87 wiz 7626: which the replacement will take place. All combinations of
7627: <code class="literal">pre-</code>, <code class="literal">do-</code> and
7628: <code class="literal">post-</code> together with a phase name are
7629: possible, though only few are actually used. Most commonly used
7630: are <code class="literal">post-patch</code> and
7631: <code class="literal">pre-configure</code>. Of these two,
7632: <code class="literal">pre-configure</code> should be preferred because
7633: then it is possible to run <span><strong class="command">bmake patch</strong></span> and
7634: have the state after applying the patches but before making any
7635: other changes. This is especially useful when you are debugging
7636: a package in order to create new patches for it. Similarly,
7637: <code class="literal">post-build</code> is preferred over
7638: <code class="literal">pre-install</code>, because the install phase should
7639: generally be kept as simple as possible. When you use
7640: <code class="literal">post-build</code>, you have the same files in the
7641: working directory that will be installed later, so you can check
7642: if the substitution has succeeded.</p>
1.79 rillig 7643: <p><code class="varname">SUBST_MESSAGE.*</code> is an optional text
1.87 wiz 7644: that is printed just before the substitution is done.</p>
1.79 rillig 7645: <p><code class="varname">SUBST_FILES.*</code> is the list of shell
1.87 wiz 7646: globbing patterns that specifies the files in which the
7647: substitution will take place. The patterns are interpreted
7648: relatively to the <code class="varname">WRKSRC</code> directory.</p>
1.79 rillig 7649: <p><code class="varname">SUBST_SED.*</code> is a list of arguments to
1.87 wiz 7650: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?sed+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">sed</span>(1)</span></a> that specify the actual substitution. Every sed
7651: command should be prefixed with <code class="literal">-e</code>, so that
7652: all SUBST blocks look uniform.</p>
1.79 rillig 7653: <p>There are some more variables, but they are so seldomly
1.87 wiz 7654: used that they are only documented in the
7655: <code class="filename">mk/subst.mk</code> file.</p>
1.79 rillig 7656: </div>
1.75 rillig 7657: </div>
7658: <div class="sect1" lang="en">
7659: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 7660: <a name="fixes.fetch"></a>18.2. Fixing problems in the <span class="emphasis"><em>fetch</em></span> phase</h2></div></div></div>
1.75 rillig 7661: <div class="sect2" lang="en">
7662: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7663: <a name="no-plain-download"></a>18.2.1. Packages whose distfiles aren't available for plain downloading</h3></div></div></div>
1.75 rillig 7664: <p>If you need to download from a dynamic URL you can set
1.87 wiz 7665: <code class="varname">DYNAMIC_MASTER_SITES</code> and a <span><strong class="command">make
7666: fetch</strong></span> will call <code class="filename">files/getsite.sh</code>
7667: with the name of each file to download as an argument, expecting
7668: it to output the URL of the directory from which to download
7669: it. <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/graphics/ns-cult3d/README.html" target="_top"><code class="filename">graphics/ns-cult3d</code></a> is an
7670: example of this usage.</p>
1.75 rillig 7671: <p>If the download can't be automated, because the user must
1.87 wiz 7672: submit personal information to apply for a password, or must pay
7673: for the source, or whatever, you can set
7674: <code class="varname">FETCH_MESSAGE</code> to a list of lines that are
7675: displayed to the user before aborting the build. Example:</p>
7676: <pre class="programlisting">
7677: FETCH_MESSAGE= "Please download the files"
7678: FETCH_MESSAGE+= " "${DISTFILES:Q}
7679: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
7680: </pre>
1.75 rillig 7681: </div>
7682: <div class="sect2" lang="en">
7683: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7684: <a name="modified-distfiles-same-name"></a>18.2.2. How to handle modified distfiles with the 'old' name</h3></div></div></div>
1.75 rillig 7685: <p>Sometimes authors of a software package make some
1.87 wiz 7686: modifications after the software was released, and they put up a
7687: new distfile without changing the package's version number. If a
7688: package is already in pkgsrc at that time, the checksum will
7689: no longer match. The contents of the new distfile should be
7690: compared against the old one before changing anything, to make
7691: sure the distfile was really updated on purpose, and that
7692: no trojan horse or so crept in.
7693: Then, the correct way to work around this is to
7694: set <code class="varname">DIST_SUBDIR</code> to a unique directory name,
7695: usually based on <code class="varname">PKGNAME_NOREV</code>. All
7696: <code class="varname">DISTFILES</code> and
7697: <code class="varname">PATCHFILES</code> for this package will be put in that
7698: subdirectory of the local distfiles directory. In case this
7699: happens more often, <code class="varname">PKGNAME</code> can be used (thus
7700: including the <code class="filename">nbX</code> suffix) or a date stamp
7701: can be appended, like <code class="varname">${PKGNAME_NOREV}-YYYYMMDD</code>.
7702: Do not forget regenerating the <code class="filename">distinfo</code> file
7703: after that, since it contains the <code class="varname">DIST_SUBDIR</code>
7704: path in the filenames.
7705: Furthermore, a mail to the package's authors seems appropriate
7706: telling them that changing distfiles after releases without
7707: changing the file names is not good practice.</p>
1.75 rillig 7708: </div>
7709: </div>
7710: <div class="sect1" lang="en">
7711: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 7712: <a name="fixes.configure"></a>18.3. Fixing problems in the <span class="emphasis"><em>configure</em></span> phase</h2></div></div></div>
1.75 rillig 7713: <div class="sect2" lang="en">
7714: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7715: <a name="fixes.libtool"></a>18.3.1. Shared libraries - libtool</h3></div></div></div>
1.75 rillig 7716: <p>pkgsrc supports many different machines, with different
1.87 wiz 7717: object formats like a.out and ELF, and varying abilities to do
7718: shared library and dynamic loading at all. To accompany this,
7719: varying commands and options have to be passed to the
7720: compiler, linker, etc. to get the Right Thing, which can be
7721: pretty annoying especially if you don't have all the machines
7722: at your hand to test things. The
7723: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/libtool/README.html" target="_top"><code class="filename">devel/libtool</code></a> pkg
7724: can help here, as it just “<span class="quote">knows</span>” how to build
7725: both static and dynamic libraries from a set of source files,
7726: thus being platform-independent.</p>
7727: <p>Here's how to use libtool in a package in seven simple
7728: steps:</p>
1.75 rillig 7729: <div class="orderedlist"><ol type="1">
7730: <li><p>Add <code class="varname">USE_LIBTOOL=yes</code> to the package
1.87 wiz 7731: Makefile.</p></li>
1.75 rillig 7732: <li><p>For library objects, use “<span class="quote">${LIBTOOL} --mode=compile
1.87 wiz 7733: ${CC}</span>” in place of “<span class="quote">${CC}</span>”. You could even
7734: add it to the definition of <code class="varname">CC</code>, if only
7735: libraries are being built in a given Makefile. This one command
7736: will build both PIC and non-PIC library objects, so you need not
7737: have separate shared and non-shared library rules.</p></li>
1.75 rillig 7738: <li>
7739: <p>For the linking of the library, remove any
1.87 wiz 7740: “<span class="quote">ar</span>”, “<span class="quote">ranlib</span>”, and “<span class="quote">ld
7741: -Bshareable</span>” commands, and instead use:</p>
1.75 rillig 7742: <pre class="programlisting">
1.87 wiz 7743: ${LIBTOOL} --mode=link ${CC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} \
7744: -rpath ${PREFIX}/lib -version-info major:minor
7745: </pre>
1.75 rillig 7746: <p>Note that the library is changed to have a
1.87 wiz 7747: <code class="filename">.la</code> extension, and the objects are
7748: changed to have a <code class="filename">.lo</code>
7749: extension. Change <code class="varname">OBJS</code> as
7750: necessary. This automatically creates all of the
7751: <code class="filename">.a</code>,
7752: <code class="filename">.so.major.minor</code>, and ELF symlinks (if
7753: necessary) in the build directory. Be sure to include
7754: “<span class="quote">-version-info</span>”, especially when major and
7755: minor are zero, as libtool will otherwise strip off the
7756: shared library version.</p>
1.75 rillig 7757: <p>From the libtool manual:</p>
7758: <pre class="programlisting">
1.87 wiz 7759: So, libtool library versions are described by three integers:
1.69 rillig 7760:
1.87 wiz 7761: CURRENT
7762: The most recent interface number that this library implements.
1.69 rillig 7763:
1.87 wiz 7764: REVISION
7765: The implementation number of the CURRENT interface.
1.69 rillig 7766:
1.87 wiz 7767: AGE
7768: The difference between the newest and oldest interfaces that
7769: this library implements. In other words, the library implements
7770: all the interface numbers in the range from number `CURRENT -
7771: AGE' to `CURRENT'.
1.1 grant 7772:
1.87 wiz 7773: If two libraries have identical CURRENT and AGE numbers, then the
7774: dynamic linker chooses the library with the greater REVISION number.
7775: </pre>
1.75 rillig 7776: <p>The “<span class="quote">-release</span>” option will produce
1.87 wiz 7777: different results for a.out and ELF (excluding symlinks)
7778: in only one case. An ELF library of the form
7779: “<span class="quote">libfoo-release.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
7780: will have a symlink of
7781: “<span class="quote">libfoo.so.<span class="emphasis"><em>x</em></span>.<span class="emphasis"><em>y</em></span></span>”
7782: on an a.out platform. This is handled
7783: automatically.</p>
1.75 rillig 7784: <p>The “<span class="quote">-rpath argument</span>” is the install
1.87 wiz 7785: directory of the library being built.</p>
1.76 rillig 7786: <p>In the <code class="filename">PLIST</code>, include only the
1.87 wiz 7787: <code class="filename">.la</code> file, the other files will be
7788: added automatically.</p>
1.75 rillig 7789: </li>
7790: <li>
1.76 rillig 7791: <p>When linking shared object (<code class="filename">.so</code>)
1.87 wiz 7792: files, i.e. files that are loaded via <a href="http://netbsd.gw.com/cgi-bin/man-cgi?dlopen+3+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">dlopen</span>(3)</span></a>, NOT
7793: shared libraries, use “<span class="quote">-module
7794: -avoid-version</span>” to prevent them getting version
7795: tacked on.</p>
1.76 rillig 7796: <p>The <code class="filename">PLIST</code> file gets the
1.87 wiz 7797: <code class="filename">foo.so</code> entry.</p>
1.75 rillig 7798: </li>
7799: <li>
7800: <p>When linking programs that depend on these libraries
1.87 wiz 7801: <span class="emphasis"><em>before</em></span> they are installed, preface
7802: the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?cc+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">cc</span>(1)</span></a> or <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ld+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ld</span>(1)</span></a> line with “<span class="quote">${LIBTOOL}
7803: --mode=link</span>”, and it will find the correct
7804: libraries (static or shared), but please be aware that
7805: libtool will not allow you to specify a relative path in
7806: -L (such as “<span class="quote">-L../somelib</span>”), because it
7807: expects you to change that argument to be the
7808: <code class="filename">.la</code> file. e.g.</p>
1.75 rillig 7809: <pre class="programlisting">
1.87 wiz 7810: ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
7811: </pre>
1.75 rillig 7812: <p>should be changed to:</p>
7813: <pre class="programlisting">
1.87 wiz 7814: ${LIBTOOL} --mode=link ${CC} -o <em class="replaceable"><code>someprog</code></em> <em class="replaceable"><code>../somelib/somelib.la</code></em>
7815: </pre>
1.75 rillig 7816: <p>and it will do the right thing with the libraries.</p>
7817: </li>
7818: <li>
7819: <p>When installing libraries, preface the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?install+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">install</span>(1)</span></a>
1.87 wiz 7820: or <a href="http://netbsd.gw.com/cgi-bin/man-cgi?cp+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">cp</span>(1)</span></a> command with “<span class="quote">${LIBTOOL}
7821: --mode=install</span>”, and change the library name to
7822: <code class="filename">.la</code>. e.g.</p>
1.75 rillig 7823: <pre class="programlisting">
1.87 wiz 7824: ${LIBTOOL} --mode=install ${BSD_INSTALL_DATA} ${SOMELIB:.a=.la} ${PREFIX}/lib
7825: </pre>
1.76 rillig 7826: <p>This will install the static <code class="filename">.a</code>,
1.87 wiz 7827: shared library, any needed symlinks, and run
7828: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?ldconfig+8+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">ldconfig</span>(8)</span></a>.</p>
1.75 rillig 7829: </li>
1.76 rillig 7830: <li><p>In your <code class="filename">PLIST</code>, include only
1.87 wiz 7831: the <code class="filename">.la</code>
7832: file (this is a change from previous behaviour).</p></li>
1.75 rillig 7833: </ol></div>
7834: </div>
7835: <div class="sect2" lang="en">
7836: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7837: <a name="using-libtool"></a>18.3.2. Using libtool on GNU packages that already support libtool</h3></div></div></div>
1.75 rillig 7838: <p>Add <code class="varname">USE_LIBTOOL=yes</code> to the
1.87 wiz 7839: package Makefile. This will override the package's own libtool
7840: in most cases. For older libtool using packages, libtool is
7841: made by ltconfig script during the do-configure step; you can
7842: check the libtool script location by doing <span><strong class="command">make
7843: configure; find work*/ -name libtool</strong></span>.</p>
1.75 rillig 7844: <p><code class="varname">LIBTOOL_OVERRIDE</code> specifies which libtool
1.87 wiz 7845: scripts, relative to <code class="varname">WRKSRC</code>, to override. By
7846: default, it is set to “<span class="quote">libtool */libtool
7847: */*/libtool</span>”. If this does not match the location of the
7848: package's libtool script(s), set it as appropriate.</p>
1.76 rillig 7849: <p>If you do not need <code class="filename">*.a</code> static
1.87 wiz 7850: libraries built and installed, then use
7851: <code class="varname">SHLIBTOOL_OVERRIDE</code> instead.</p>
1.75 rillig 7852: <p>If your package makes use of the platform-independent library
1.87 wiz 7853: for loading dynamic shared objects, that comes with libtool
7854: (libltdl), you should include devel/libltdl/buildlink3.mk.</p>
7855: <p>Some packages use libtool incorrectly so that the package
7856: may not work or build in some circumstances. Some of the more
7857: common errors are:</p>
1.75 rillig 7858: <div class="itemizedlist"><ul type="disc">
7859: <li>
7860: <p>The inclusion of a shared object (-module) as a dependent library in an
1.87 wiz 7861: executable or library. This in itself isn't a problem if one of two things
7862: has been done:</p>
1.75 rillig 7863: <div class="orderedlist"><ol type="1">
7864: <li><p>The shared object is named correctly, i.e.
1.87 wiz 7865: <code class="filename">libfoo.la</code>, not
7866: <code class="filename">foo.la</code></p></li>
1.75 rillig 7867: <li><p>The -dlopen option is used when linking an executable.</p></li>
7868: </ol></div>
7869: </li>
7870: <li><p>The use of libltdl without the correct calls to initialisation routines.
1.87 wiz 7871: The function lt_dlinit() should be called and the macro
7872: <code class="varname">LTDL_SET_PRELOADED_SYMBOLS</code> included in
7873: executables.</p></li>
1.75 rillig 7874: </ul></div>
7875: </div>
7876: <div class="sect2" lang="en">
7877: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7878: <a name="autoconf-automake"></a>18.3.3. GNU Autoconf/Automake</h3></div></div></div>
1.75 rillig 7879: <p>If a package needs GNU autoconf or automake to be executed
1.87 wiz 7880: to regenerate the configure script and Makefile.in makefile
7881: templates, then they should be executed in a pre-configure
7882: target.</p>
1.75 rillig 7883: <p>For packages that need only autoconf:</p>
7884: <pre class="programlisting">
1.87 wiz 7885: AUTOCONF_REQD= 2.50 # if default version is not good enough
7886: USE_TOOLS+= autoconf # use "autoconf213" for autoconf-2.13
7887: ...
1.1 grant 7888:
1.87 wiz 7889: pre-configure:
7890: cd ${WRKSRC}; autoconf
1.1 grant 7891:
1.87 wiz 7892: ...
7893: </pre>
1.75 rillig 7894: <p>and for packages that need automake and autoconf:</p>
7895: <pre class="programlisting">
1.87 wiz 7896: AUTOMAKE_REQD= 1.7.1 # if default version is not good enough
7897: USE_TOOLS+= automake # use "automake14" for automake-1.4
7898: ...
7899:
7900: pre-configure:
7901: cd ${WRKSRC}; \
7902: aclocal; autoheader; \
7903: automake -a --foreign -i; autoconf
1.1 grant 7904:
1.87 wiz 7905: ...
7906: </pre>
1.75 rillig 7907: <p>Packages which use GNU Automake will almost certainly
1.87 wiz 7908: require GNU Make.</p>
1.75 rillig 7909: <p>There are times when the configure process makes
1.87 wiz 7910: additional changes to the generated files, which then causes
7911: the build process to try to re-execute the automake sequence.
7912: This is prevented by touching various files in the configure
7913: stage. If this causes problems with your package you can set
7914: <code class="varname">AUTOMAKE_OVERRIDE=NO</code> in the package
7915: Makefile.</p>
1.75 rillig 7916: </div>
7917: </div>
7918: <div class="sect1" lang="en">
7919: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 7920: <a name="programming-languages"></a>18.4. Programming languages</h2></div></div></div>
1.87 wiz 7921: <div class="sect2" lang="en">
7922: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7923: <a name="basic-programming-languages"></a>18.4.1. C, C++, and Fortran</h3></div></div></div>
1.87 wiz 7924: <p>Compilers for the C, C++, and Fortran languages comes with
7925: the NetBSD base system. By default, pkgsrc assumes that a package
7926: is written in C and will hide all other compilers (via the wrapper
1.90 ! rillig 7927: framework, see <a href="#buildlink" title="Chapter 13. Buildlink methodology">Chapter 13, <i>Buildlink methodology</i></a>).</p>
1.87 wiz 7928: <p>To declare which language's compiler a package needs, set
7929: the <code class="varname">USE_LANGUAGES</code> variable. Allowed values
7930: currently are “<span class="quote">c</span>”, “<span class="quote">c++</span>”, and
7931: “<span class="quote">fortran</span>” (and any combination). The default is
7932: “<span class="quote">c</span>”. Packages using GNU configure scripts, even if
7933: written in C++, usually need a C compiler for the configure
7934: phase.</p>
7935: </div>
7936: <div class="sect2" lang="en">
7937: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7938: <a name="java-programming-language"></a>18.4.2. Java</h3></div></div></div>
1.87 wiz 7939: <p>If a program is written in Java, use the Java framework in
7940: pkgsrc. The package must include
7941: <code class="filename">../../mk/java-vm.mk</code>. This Makefile fragment
7942: provides the following variables:</p>
7943: <div class="itemizedlist"><ul type="disc">
7944: <li><p><code class="varname">USE_JAVA</code> defines if a build
7945: dependency on the JDK is added. If
7946: <code class="varname">USE_JAVA</code> is set to “<span class="quote">run</span>”, then
7947: there is only a runtime dependency on the JDK. The default is
7948: “<span class="quote">yes</span>”, which also adds a build dependency on the
7949: JDK.</p></li>
7950: <li><p>Set <code class="varname">USE_JAVA2</code> to declare that
7951: a package needs a Java2 implementation. The supported values
7952: are “<span class="quote">yes</span>”, “<span class="quote">1.4</span>”, and
7953: “<span class="quote">1.5</span>”. “<span class="quote">yes</span>” accepts any Java2
7954: implementation, “<span class="quote">1.4</span>” insists on versions 1.4 or
7955: above, and “<span class="quote">1.5</span>” only accepts versions 1.5 or
7956: above. This variable is not set by default.</p></li>
7957: </ul></div>
7958: </div>
7959: <div class="sect2" lang="en">
7960: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7961: <a name="perl-scripts"></a>18.4.3. Packages containing perl scripts</h3></div></div></div>
1.87 wiz 7962: <p>If your package contains interpreted perl scripts, add
7963: “<span class="quote">perl</span>” to the <code class="varname">USE_TOOLS</code> variable
7964: and set <code class="varname">REPLACE_PERL</code> to ensure that the proper
7965: interpreter path is set. <code class="varname">REPLACE_PERL</code> should
7966: contain a list of scripts, relative to <code class="varname">WRKSRC</code>,
7967: that you want adjusted. Every occurrence of
7968: <code class="filename">*/bin/perl</code> will be replaced with the full
7969: path to the perl executable.</p>
7970: <p>If a particular version of perl is needed, set the
7971: <code class="varname">PERL5_REQD</code> variable to the version number. The
7972: default is “<span class="quote">5.0</span>”.</p>
1.90 ! rillig 7973: <p>See <a href="#perl-modules" title="18.6.5. Packages installing perl modules">Section 18.6.5, “Packages installing perl modules”</a> for information
1.87 wiz 7974: about handling perl modules.</p>
7975: </div>
7976: <div class="sect2" lang="en">
7977: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7978: <a name="other-programming-languages"></a>18.4.4. Other programming languages</h3></div></div></div>
1.87 wiz 7979: <p>Currently, there is no special handling for other languages
7980: in pkgsrc. If a compiler package provides a
7981: <code class="filename">buildlink3.mk</code> file, include that, otherwise
7982: just add a (build) dependency on the appropriate compiler
7983: package.</p>
7984: </div>
7985: </div>
7986: <div class="sect1" lang="en">
7987: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 7988: <a name="fixes.build"></a>18.5. Fixing problems in the <span class="emphasis"><em>build</em></span> phase</h2></div></div></div>
1.77 rillig 7989: <p>The most common failures when building a package are that
7990: some platforms do not provide certain header files, functions or
7991: libraries, or they provide the functions in a library that the
7992: original package author didn't know. To work around this, you
7993: can rewrite the source code in most cases so that it does not
7994: use the missing functions or provides a replacement function.</p>
7995: <div class="sect2" lang="en">
7996: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 7997: <a name="fixes.build.cpp"></a>18.5.1. Compiling C and C++ code conditionally</h3></div></div></div>
1.77 rillig 7998: <p>If a package already comes with a GNU configure script, the
7999: preferred way to fix the build failure is to change the
8000: configure script, not the code. In the other cases, you can
8001: utilize the C preprocessor, which defines certain macros
8002: depending on the operating system and hardware architecture it
8003: compiles for. These macros can be queried using for example
8004: <code class="varname">#if defined(__i386)</code>. Almost every operating
8005: system, hardware architecture and compiler has its own macro.
8006: For example, if the macros <code class="varname">__GNUC__</code>,
8007: <code class="varname">__i386__</code> and <code class="varname">__NetBSD__</code>
8008: are all defined, you know that you are using NetBSD on an i386
8009: compatible CPU, and your compiler is GCC.</p>
8010: <p>The list of the following macros for hardware and
8011: operating system depends on the compiler that is used. For
8012: example, if you want to conditionally compile code on Solaris,
8013: don't use <code class="varname">__sun__</code>, as the SunPro compiler
8014: does not define it. Use <code class="varname">__sun</code> instead.</p>
1.75 rillig 8015: <div class="sect3" lang="en">
8016: <div class="titlepage"><div><div><h4 class="title">
1.90 ! rillig 8017: <a name="fixes.build.cpp.os"></a>18.5.1.1. C preprocessor macros to identify the operating system</h4></div></div></div>
1.75 rillig 8018: <p>To distinguish between 4.4 BSD-derived systems and the
8019: rest of the world, you should use the following code.</p>
8020: <pre class="programlisting">
8021: #include <sys/param.h>
8022: #if (defined(BSD) && BSD >= 199306)
8023: /* BSD-specific code goes here */
8024: #else
8025: /* non-BSD-specific code goes here */
8026: #endif
8027: </pre>
1.77 rillig 8028: <p>If this distinction is not fine enough, you can also test
8029: for the following macros.</p>
1.75 rillig 8030: <pre class="programlisting">
8031: FreeBSD __FreeBSD__
8032: DragonFly __DragonFly__
8033: Interix __INTERIX
8034: Linux linux, __linux, __linux__
8035: NetBSD __NetBSD__
8036: OpenBSD __OpenBSD__
8037: Solaris sun, __sun
8038: </pre>
8039: </div>
8040: <div class="sect3" lang="en">
8041: <div class="titlepage"><div><div><h4 class="title">
1.90 ! rillig 8042: <a name="fixes.build.cpp.arch"></a>18.5.1.2. C preprocessor macros to identify the hardware architecture</h4></div></div></div>
1.75 rillig 8043: <pre class="programlisting">
8044: i386 i386, __i386, __i386__
8045: MIPS __mips
8046: SPARC sparc, __sparc
8047: </pre>
8048: </div>
8049: <div class="sect3" lang="en">
8050: <div class="titlepage"><div><div><h4 class="title">
1.90 ! rillig 8051: <a name="fixes.build.cpp.compiler"></a>18.5.1.3. C preprocessor macros to identify the compiler</h4></div></div></div>
1.75 rillig 8052: <pre class="programlisting">
8053: GCC __GNUC__ (major version), __GNUC_MINOR__
8054: SunPro __SUNPRO_C (0x570 for version 5.7)
1.81 rillig 8055: SunPro C++ __SUNPRO_CC (0x580 for version 5.8)
1.75 rillig 8056: </pre>
8057: </div>
8058: </div>
1.78 rillig 8059: <div class="sect2" lang="en">
8060: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8061: <a name="compiler-bugs"></a>18.5.2. How to handle compiler bugs</h3></div></div></div>
1.78 rillig 8062: <p>Some source files trigger bugs in the compiler, based on
1.87 wiz 8063: combinations of compiler version and architecture and almost
8064: always relation to optimisation being enabled. Common symptoms
8065: are gcc internal errors or never finishing compiling a
1.78 rillig 8066: file.</p>
8067: <p>Typically, a workaround involves testing the
8068: <code class="varname">MACHINE_ARCH</code> and compiler version, disabling
8069: optimisation for that combination of file,
8070: <code class="varname">MACHINE_ARCH</code> and compiler, and documenting it
1.87 wiz 8071: in <code class="filename">pkgsrc/doc/HACKS</code>. See that file for a
1.78 rillig 8072: number of examples.</p>
8073: </div>
8074: <div class="sect2" lang="en">
8075: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8076: <a name="undefined-reference"></a>18.5.3. Undefined reference to “<span class="quote">...</span>”</h3></div></div></div>
1.78 rillig 8077: <p>This compiler error often means that a package did not
8078: link to a shared library it needs. The following functions are
8079: known to cause this error message over and over.</p>
8080: <div class="informaltable">
8081: <a name="undefined-reference-functions"></a><table border="1">
8082: <colgroup>
8083: <col>
8084: <col>
8085: <col>
8086: </colgroup>
8087: <thead><tr>
8088: <th>Function</th>
8089: <th>Library</th>
8090: <th>Affected platforms</th>
8091: </tr></thead>
8092: <tbody>
8093: <tr>
8094: <td>accept, bind, connect</td>
8095: <td>-lsocket</td>
8096: <td>Solaris</td>
8097: </tr>
8098: <tr>
8099: <td>crypt</td>
8100: <td>-lcrypt</td>
8101: <td>DragonFly, NetBSD</td>
8102: </tr>
8103: <tr>
8104: <td>dlopen, dlsym</td>
8105: <td>-ldl</td>
8106: <td>Linux</td>
8107: </tr>
8108: <tr>
8109: <td>gethost*</td>
8110: <td>-lnsl</td>
8111: <td>Solaris</td>
8112: </tr>
8113: <tr>
8114: <td>inet_aton</td>
8115: <td>-lresolv</td>
8116: <td>Solaris</td>
8117: </tr>
8118: <tr>
8119: <td>nanosleep, sem_*, timer_*</td>
8120: <td>-lrt</td>
8121: <td>Solaris</td>
8122: </tr>
8123: <tr>
8124: <td>openpty</td>
8125: <td>-lutil</td>
8126: <td>Linux</td>
8127: </tr>
8128: </tbody>
8129: </table>
8130: </div>
8131: <p>To fix these linker errors, it is often sufficient to say
1.87 wiz 8132: <code class="literal">LIBS.<em class="replaceable"><code>OperatingSystem</code></em>+=
8133: -l<em class="replaceable"><code>foo</code></em></code> to the package
8134: <code class="filename">Makefile</code> and then say <span><strong class="command">bmake clean;
8135: bmake</strong></span>.</p>
8136: </div>
8137: <div class="sect2" lang="en">
8138: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8139: <a name="out-of-memory"></a>18.5.4. Running out of memory</h3></div></div></div>
1.87 wiz 8140: <p>Sometimes packages fail to build because the compiler runs
8141: into an operating system specific soft limit. With the
8142: <code class="varname">UNLIMIT_RESOURCES</code> variable pkgsrc can be told
8143: to unlimit the resources. Currently, the allowed values are
8144: “<span class="quote">datasize</span>” and “<span class="quote">stacksize</span>” (or both).
8145: Setting this variable is similar to running the shell builtin
8146: <span><strong class="command">ulimit</strong></span> command to raise the maximum data
8147: segment size or maximum stack size of a process, respectively, to
8148: their hard limits.</p>
1.78 rillig 8149: </div>
1.75 rillig 8150: </div>
8151: <div class="sect1" lang="en">
8152: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 8153: <a name="fixes.install"></a>18.6. Fixing problems in the <span class="emphasis"><em>install</em></span> phase</h2></div></div></div>
1.75 rillig 8154: <div class="sect2" lang="en">
8155: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8156: <a name="install-scripts"></a>18.6.1. Creating needed directories</h3></div></div></div>
1.78 rillig 8157: <p>The BSD-compatible <span><strong class="command">install</strong></span> supplied
1.87 wiz 8158: with some operating systems cannot create more than one
8159: directory at a time. As such, you should call
8160: <code class="literal">${INSTALL_*_DIR}</code> like this:</p>
8161: <pre class="programlisting">
8162: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
8163: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
8164: </pre>
1.78 rillig 8165: <p>You can also just append “<span class="quote"><code class="literal">dir1
1.87 wiz 8166: dir2</code></span>” to the
8167: <code class="varname">INSTALLATION_DIRS</code> variable, which will
8168: automatically do the right thing.</p>
1.75 rillig 8169: </div>
8170: <div class="sect2" lang="en">
8171: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8172: <a name="where-to-install-documentation"></a>18.6.2. Where to install documentation</h3></div></div></div>
1.83 wiz 8173: <p>In general, documentation should be installed into
1.87 wiz 8174: <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
8175: <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code> (the latter
8176: includes the version number of the package).</p>
1.84 wiz 8177: <p>Many modern packages using GNU autoconf allow to set the
1.87 wiz 8178: directory where HTML documentation is installed with the
8179: “<span class="quote">--with-html-dir</span>” option. Sometimes using this flag
8180: is needed because otherwise the documentation ends up in
8181: <code class="filename">${PREFIX}/share/doc/html</code> or other
8182: places.</p>
8183: <p>An exception to the above is that library API documentation
8184: generated with the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/textproc/gtk-doc/README.html" target="_top"><code class="filename">textproc/gtk-doc</code></a> tools, for use by special
8185: browsers (devhelp) should be left at their default location, which
8186: is <code class="filename">${PREFIX}/share/gtk-doc</code>. Such
8187: documentation can be recognized from files ending in
8188: <code class="filename">.devhelp</code> or <code class="filename">.devhelp2</code>.
8189: (It is also acceptable to install such files in
8190: <code class="filename">${PREFIX}/share/doc/${PKGBASE}</code> or
8191: <code class="filename">${PREFIX}/share/doc/${PKGNAME}</code>; the
8192: <code class="filename">.devhelp*</code> file must be directly in that
8193: directory then, no additional subdirectory level is allowed in
8194: this case. This is usually achieved by using
8195: “<span class="quote">--with-html-dir=${PREFIX}/share/doc</span>”.
8196: <code class="filename">${PREFIX}/share/gtk-doc</code> is preferred
8197: though.)</p>
1.75 rillig 8198: </div>
8199: <div class="sect2" lang="en">
8200: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8201: <a name="installing-score-files"></a>18.6.3. Installing score files</h3></div></div></div>
1.75 rillig 8202: <p>Certain packages, most of them in the games category, install
1.87 wiz 8203: a score file that allows all users on the system to record their
8204: highscores. In order for this to work, the binaries need to be
8205: installed setgid and the score files owned by the appropriate
8206: group and/or owner (traditionally the "games" user/group). The
8207: following variables, documented in more detail in
8208: <code class="filename">mk/defaults/mk.conf</code>, control this
8209: behaviour: <code class="varname">SETGIDGAME</code>,
8210: <code class="varname">GAMEDATAMODE</code>, <code class="varname">GAMEGRP</code>,
8211: <code class="varname">GAMEMODE</code>, <code class="varname">GAMEOWN</code>.</p>
1.75 rillig 8212: <p>Note that per default, setgid installation of games is
1.87 wiz 8213: disabled; setting <code class="varname">SETGIDGAME=YES</code> will set all
8214: the other variables accordingly.</p>
1.75 rillig 8215: <p>A package should therefor never hard code file ownership or
1.87 wiz 8216: access permissions but rely on <code class="varname">INSTALL_GAME</code> and
8217: <code class="varname">INSTALL_GAME_DATA</code> to set these
8218: correctly.</p>
1.75 rillig 8219: </div>
8220: <div class="sect2" lang="en">
8221: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8222: <a name="hardcoded-paths"></a>18.6.4. Packages with hardcoded paths to other interpreters</h3></div></div></div>
1.87 wiz 8223: <p>Your package may also contain scripts with hardcoded paths to
8224: other interpreters besides (or as well as) perl. To correct the
8225: full pathname to the script interpreter, you need to set the
8226: following definitions in your <code class="filename">Makefile</code> (we
8227: shall use <span><strong class="command">tclsh</strong></span> in this example):</p>
8228: <pre class="programlisting">
8229: REPLACE_INTERPRETER+= tcl
8230: REPLACE.tcl.old= .*/bin/tclsh
8231: REPLACE.tcl.new= ${PREFIX}/bin/tclsh
8232: REPLACE_FILES.tcl= # list of tcl scripts which need to be fixed,
8233: # relative to ${WRKSRC}, just as in REPLACE_PERL
8234: </pre>
1.75 rillig 8235: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
8236: <h3 class="title">Note</h3>
8237: <p>Before March 2006, these variables were called
1.87 wiz 8238: <code class="varname">_REPLACE.*</code> and
8239: <code class="varname">_REPLACE_FILES.*</code>.</p>
1.75 rillig 8240: </div>
8241: </div>
8242: <div class="sect2" lang="en">
8243: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8244: <a name="perl-modules"></a>18.6.5. Packages installing perl modules</h3></div></div></div>
1.75 rillig 8245: <p>Makefiles of packages providing perl5 modules should include
1.87 wiz 8246: the Makefile fragment
8247: <code class="filename">../../lang/perl5/module.mk</code>. It provides a
8248: <span><strong class="command">do-configure</strong></span> target for the standard perl
8249: configuration for such modules as well as various hooks to tune
8250: this configuration. See comments in this file for
8251: details.</p>
1.75 rillig 8252: <p>Perl5 modules will install into different places depending
1.87 wiz 8253: on the version of perl used during the build process. To
8254: address this, pkgsrc will append lines to the
8255: <code class="filename">PLIST</code> corresponding to the files listed in
8256: the installed <code class="filename">.packlist</code> file generated by
8257: most perl5 modules. This is invoked by defining
8258: <code class="varname">PERL5_PACKLIST</code> to a space-separated list of
8259: paths to packlist files, e.g.:</p>
1.75 rillig 8260: <pre class="programlisting">
1.87 wiz 8261: PERL5_PACKLIST= ${PERL5_SITEARCH}/auto/Pg/.packlist
8262: </pre>
1.75 rillig 8263: <p>The variables <code class="varname">PERL5_SITELIB</code>,
1.87 wiz 8264: <code class="varname">PERL5_SITEARCH</code>, and
8265: <code class="varname">PERL5_ARCHLIB</code> represent the three locations
8266: in which perl5 modules may be installed, and may be used by
8267: perl5 packages that don't have a packlist. These three
8268: variables are also substituted for in the
8269: <code class="filename">PLIST</code>.</p>
1.75 rillig 8270: </div>
8271: <div class="sect2" lang="en">
8272: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8273: <a name="faq.info-files"></a>18.6.6. Packages installing info files</h3></div></div></div>
1.75 rillig 8274: <p>Some packages install info files or use the
1.87 wiz 8275: “<span class="quote">makeinfo</span>” or “<span class="quote">install-info</span>”
8276: commands. <code class="varname">INFO_FILES</code> should be defined in
8277: the package Makefile so that <code class="filename">INSTALL</code> and
8278: <code class="filename">DEINSTALL</code> scripts will be generated to
8279: handle registration of the info files in the Info directory
8280: file. The “<span class="quote">install-info</span>” command used for the info
8281: files registration is either provided by the system, or by a
8282: special purpose package automatically added as dependency if
8283: needed.</p>
1.75 rillig 8284: <p><code class="varname">PKGINFODIR</code> is the directory under
1.87 wiz 8285: <code class="filename">${PREFIX}</code> where info files are primarily
8286: located. <code class="varname">PKGINFODIR</code> defaults to
8287: “<span class="quote">info</span>” and can be overridden by the user.</p>
1.75 rillig 8288: <p>The info files for the package should be listed in the
1.87 wiz 8289: package <code class="filename">PLIST</code>; however any split info files
8290: need not be listed.</p>
1.75 rillig 8291: <p>A package which needs the “<span class="quote">makeinfo</span>” command
1.87 wiz 8292: at build time must add “<span class="quote">makeinfo</span>” to
8293: <code class="varname">USE_TOOLS</code> in its Makefile. If a minimum
8294: version of the “<span class="quote">makeinfo</span>” command is needed it
8295: should be noted with the <code class="varname">TEXINFO_REQD</code>
8296: variable in the package <code class="filename">Makefile</code>. By
8297: default, a minimum version of 3.12 is required. If the system
8298: does not provide a <span><strong class="command">makeinfo</strong></span> command or if it
8299: does not match the required minimum, a build dependency on the
8300: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/devel/gtexinfo/README.html" target="_top"><code class="filename">devel/gtexinfo</code></a> package will
8301: be added automatically.</p>
1.75 rillig 8302: <p>The build and installation process of the software provided
1.87 wiz 8303: by the package should not use the
8304: <span><strong class="command">install-info</strong></span> command as the registration of
8305: info files is the task of the package
8306: <code class="filename">INSTALL</code> script, and it must use the
8307: appropriate <span><strong class="command">makeinfo</strong></span> command.</p>
1.75 rillig 8308: <p>To achieve this goal, the pkgsrc infrastructure creates
1.87 wiz 8309: overriding scripts for the <span><strong class="command">install-info</strong></span> and
8310: <span><strong class="command">makeinfo</strong></span> commands in a directory listed early
8311: in <code class="varname">PATH</code>.</p>
1.75 rillig 8312: <p>The script overriding <span><strong class="command">install-info</strong></span> has
1.87 wiz 8313: no effect except the logging of a message. The script overriding
8314: <span><strong class="command">makeinfo</strong></span> logs a message and according to the
8315: value of <code class="varname">TEXINFO_REQD</code> either runs the appropriate
8316: <span><strong class="command">makeinfo</strong></span> command or exit on error.</p>
1.75 rillig 8317: </div>
8318: <div class="sect2" lang="en">
8319: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8320: <a name="manpages"></a>18.6.7. Packages installing man pages</h3></div></div></div>
1.81 rillig 8321: <p>All packages that install manual pages should install them
1.87 wiz 8322: into the same directory, so that there is one common place to look
8323: for them. In pkgsrc, this place is
8324: <code class="literal">${PREFIX}/${PKGMANDIR}</code>, and this expression
8325: should be used in packages. The default for
8326: <code class="varname">PKGMANDIR</code> is
8327: “<span class="quote"><code class="filename">man</code></span>”. Another often-used value
8328: is “<span class="quote"><code class="filename">share/man</code></span>”.</p>
1.75 rillig 8329: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
8330: <h3 class="title">Note</h3>
1.87 wiz 8331: <p>The support for a custom <code class="varname">PKGMANDIR</code>
8332: is far from complete.</p>
1.75 rillig 8333: </div>
1.81 rillig 8334: <p>The <code class="filename">PLIST</code> files can just use
1.87 wiz 8335: <code class="filename">man/</code> as the top level directory for the man
8336: page file entries, and the pkgsrc framework will convert as
8337: needed. In all other places, the correct
8338: <code class="varname">PKGMANDIR</code> must be used.</p>
8339: <p>Packages that are
8340: configured with <code class="varname">GNU_CONFIGURE</code> set as
8341: “<span class="quote">yes</span>”, by default will use the
8342: <code class="filename">./configure</code>
8343: --mandir switch to set where the man pages should be installed.
8344: The path is <code class="varname">GNU_CONFIGURE_MANDIR</code> which defaults
8345: to <code class="varname">${PREFIX}/${PKGMANDIR}</code>.</p>
8346: <p>Packages that use <code class="varname">GNU_CONFIGURE</code> but do not
8347: use --mandir, can set <code class="varname">CONFIGURE_HAS_MANDIR</code>
8348: to “<span class="quote">no</span>”.
8349: Or if the <code class="filename">./configure</code> script uses
8350: a non-standard use of --mandir, you can set
8351: <code class="varname">GNU_CONFIGURE_MANDIR</code> as needed.</p>
1.90 ! rillig 8352: <p>See <a href="#manpage-compression" title="12.5. Man page compression">Section 12.5, “Man page compression”</a> for
1.87 wiz 8353: information on installation of compressed manual pages.</p>
1.75 rillig 8354: </div>
8355: <div class="sect2" lang="en">
8356: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8357: <a name="gconf2-data-files"></a>18.6.8. Packages installing GConf2 data files</h3></div></div></div>
1.87 wiz 8358: <p>If a package installs <code class="filename">.schemas</code> or
8359: <code class="filename">.entries</code> files, used by GConf2,
8360: you need to take some extra steps to make sure they get registered
8361: in the database:</p>
1.75 rillig 8362: <div class="orderedlist"><ol type="1">
1.76 rillig 8363: <li><p>Include <code class="filename">../../devel/GConf2/schemas.mk</code>
1.87 wiz 8364: instead of its <code class="filename">buildlink3.mk</code> file. This
8365: takes care of rebuilding the GConf2 database at installation and
8366: deinstallation time, and tells the package where to install
8367: GConf2 data files using some standard configure arguments. It
8368: also disallows any access to the database directly from the
8369: package.</p></li>
1.75 rillig 8370: <li><p>Ensure that the package installs its
1.87 wiz 8371: <code class="filename">.schemas</code> files under
8372: <code class="filename">${PREFIX}/share/gconf/schemas</code>. If they get
8373: installed under <code class="filename">${PREFIX}/etc</code>, you will
8374: need to manually patch the package.</p></li>
1.75 rillig 8375: <li><p>Check the PLIST and remove any entries under the etc/gconf
1.87 wiz 8376: directory, as they will be handled automatically. See
1.90 ! rillig 8377: <a href="#faq.conf" title="8.14. How do I change the location of configuration files?">Section 8.14, “How do I change the location of configuration files?”</a> for more information.</p></li>
1.75 rillig 8378: <li><p>Define the <code class="varname">GCONF2_SCHEMAS</code> variable in
1.87 wiz 8379: your <code class="filename">Makefile</code> with a list of all
8380: <code class="filename">.schemas</code> files installed by the package, if
8381: any. Names must not contain any directories in them.</p></li>
1.75 rillig 8382: <li><p>Define the <code class="varname">GCONF2_ENTRIES</code> variable in
1.87 wiz 8383: your <code class="filename">Makefile</code> with a
8384: list of all <code class="filename">.entries</code> files installed by the
8385: package, if any. Names must not contain any directories in
8386: them.</p></li>
1.75 rillig 8387: </ol></div>
8388: </div>
8389: <div class="sect2" lang="en">
8390: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8391: <a name="scrollkeeper-data-files"></a>18.6.9. Packages installing scrollkeeper data files</h3></div></div></div>
1.87 wiz 8392: <p>If a package installs <code class="filename">.omf</code> files, used by
8393: scrollkeeper, you need to take some extra steps to make sure they
8394: get registered in the database:</p>
1.75 rillig 8395: <div class="orderedlist"><ol type="1">
8396: <li><p>Include
1.87 wiz 8397: <code class="filename">../../textproc/scrollkeeper/omf.mk</code>
8398: instead of its <code class="filename">buildlink3.mk</code> file. This
8399: takes care of rebuilding the scrollkeeper database at
8400: installation and deinstallation time, and disallows any access
8401: to it directly from the package.</p></li>
1.75 rillig 8402: <li><p>Check the PLIST and remove any entries under the
1.87 wiz 8403: <code class="filename">libdata/scrollkeeper</code> directory, as they
8404: will be handled automatically.</p></li>
1.76 rillig 8405: <li><p>Remove the <code class="filename">share/omf</code> directory from
1.87 wiz 8406: the PLIST. It will be handled by scrollkeeper.</p></li>
1.75 rillig 8407: </ol></div>
8408: </div>
8409: <div class="sect2" lang="en">
8410: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8411: <a name="x11-fonts"></a>18.6.10. Packages installing X11 fonts</h3></div></div></div>
1.75 rillig 8412: <p>If a package installs font files, you will need to rebuild
1.87 wiz 8413: the fonts database in the directory where they get installed at
8414: installation and deinstallation time. This can be automatically
8415: done by using the pkginstall framework.</p>
1.75 rillig 8416: <p>You can list the directories where fonts are installed in the
1.87 wiz 8417: <code class="varname">FONTS_DIRS.<em class="replaceable"><code>type</code></em></code>
8418: variables, where <em class="replaceable"><code>type</code></em> can be one of
8419: “<span class="quote">ttf</span>”, “<span class="quote">type1</span>” or “<span class="quote">x11</span>”.
8420: Also make sure that the database file
8421: <code class="filename">fonts.dir</code> is not listed in the PLIST.</p>
1.75 rillig 8422: <p>Note that you should not create new directories for fonts;
1.87 wiz 8423: instead use the standard ones to avoid that the user needs to
8424: manually configure his X server to find them.</p>
1.75 rillig 8425: </div>
8426: <div class="sect2" lang="en">
8427: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8428: <a name="gtk2-modules"></a>18.6.11. Packages installing GTK2 modules</h3></div></div></div>
1.75 rillig 8429: <p>If a package installs GTK2 immodules or loaders, you need to
1.87 wiz 8430: take some extra steps to get them registered in the GTK2 database
8431: properly:</p>
1.75 rillig 8432: <div class="orderedlist"><ol type="1">
8433: <li><p>Include
1.87 wiz 8434: <code class="filename">../../x11/gtk2/modules.mk</code> instead of its
8435: <code class="filename">buildlink3.mk</code> file. This takes care of
8436: rebuilding the database at installation and deinstallation time.</p></li>
8437: <li><p>Set <code class="varname">GTK2_IMMODULES=YES</code> if
8438: your package installs GTK2 immodules.</p></li>
8439: <li><p>Set <code class="varname">GTK2_LOADERS=YES</code> if your package installs
8440: GTK2 loaders.</p></li>
1.75 rillig 8441: <li>
1.87 wiz 8442: <p>Patch the package to not touch any of the GTK2
8443: databases directly. These are:</p>
1.75 rillig 8444: <div class="itemizedlist"><ul type="disc">
1.76 rillig 8445: <li><p><code class="filename">libdata/gtk-2.0/gdk-pixbuf.loaders</code></p></li>
8446: <li><p><code class="filename">libdata/gtk-2.0/gtk.immodules</code></p></li>
1.75 rillig 8447: </ul></div>
8448: </li>
1.87 wiz 8449: <li><p>Check the <code class="filename">PLIST</code> and remove
8450: any entries under the <code class="filename">libdata/gtk-2.0</code>
8451: directory, as they will be handled automatically.</p></li>
1.75 rillig 8452: </ol></div>
8453: </div>
8454: <div class="sect2" lang="en">
8455: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8456: <a name="sgml-xml-data"></a>18.6.12. Packages installing SGML or XML data</h3></div></div></div>
1.75 rillig 8457: <p>If a package installs SGML or XML data files that need to be
1.87 wiz 8458: registered in system-wide catalogs (like DTDs, sub-catalogs,
8459: etc.), you need to take some extra steps:</p>
1.75 rillig 8460: <div class="orderedlist"><ol type="1">
8461: <li><p>Include
1.87 wiz 8462: <code class="filename">../../textproc/xmlcatmgr/catalogs.mk</code> in
8463: your <code class="filename">Makefile</code>, which takes care of
8464: registering those files in system-wide catalogs at
8465: installation and deinstallation time.</p></li>
1.75 rillig 8466: <li><p>Set <code class="varname">SGML_CATALOGS</code> to the full path of
1.87 wiz 8467: any SGML catalogs installed by the package.</p></li>
1.75 rillig 8468: <li><p>Set <code class="varname">XML_CATALOGS</code> to the full path of
1.87 wiz 8469: any XML catalogs installed by the package.</p></li>
1.75 rillig 8470: <li><p>Set <code class="varname">SGML_ENTRIES</code> to individual entries
1.87 wiz 8471: to be added to the SGML catalog. These come in groups of
8472: three strings; see xmlcatmgr(1) for more information
8473: (specifically, arguments recognized by the 'add' action).
8474: Note that you will normally not use this variable.</p></li>
1.75 rillig 8475: <li><p>Set <code class="varname">XML_ENTRIES</code> to individual entries
1.87 wiz 8476: to be added to the XML catalog. These come in groups of three
8477: strings; see xmlcatmgr(1) for more information (specifically,
8478: arguments recognized by the 'add' action). Note that you will
8479: normally not use this variable.</p></li>
1.75 rillig 8480: </ol></div>
8481: </div>
8482: <div class="sect2" lang="en">
8483: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8484: <a name="mime-database"></a>18.6.13. Packages installing extensions to the MIME database</h3></div></div></div>
1.75 rillig 8485: <p>If a package provides extensions to the MIME database by
1.87 wiz 8486: installing <code class="filename">.xml</code> files inside
8487: <code class="filename">${PREFIX}/share/mime/packages</code>, you
8488: need to take some extra steps to ensure that the database is kept
8489: consistent with respect to these new files:</p>
1.75 rillig 8490: <div class="orderedlist"><ol type="1">
8491: <li><p>Include
1.87 wiz 8492: <code class="filename">../../databases/shared-mime-info/mimedb.mk</code>
8493: (avoid using the <code class="filename">buildlink3.mk</code> file from
8494: this same directory, which is reserved for inclusion from
8495: other <code class="filename">buildlink3.mk</code> files). It takes
8496: care of rebuilding the MIME database at installation and
8497: deinstallation time, and disallows any access to it directly
8498: from the package.</p></li>
1.75 rillig 8499: <li><p>Check the PLIST and remove any entries under the
1.87 wiz 8500: <code class="filename">share/mime</code> directory,
8501: <span class="emphasis"><em>except</em></span> for files saved under
8502: <code class="filename">share/mime/packages</code>. The former are
8503: handled automatically by
8504: the update-mime-database program, but the latter are
8505: package-dependent and must be removed by the package that
8506: installed them in the first place.</p></li>
1.76 rillig 8507: <li><p>Remove any <code class="filename">share/mime/*</code> directories
1.87 wiz 8508: from the PLIST. They will be handled by the shared-mime-info
8509: package.</p></li>
1.75 rillig 8510: </ol></div>
8511: </div>
8512: <div class="sect2" lang="en">
8513: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8514: <a name="intltool"></a>18.6.14. Packages using intltool</h3></div></div></div>
1.75 rillig 8515: <p>If a package uses intltool during its build, include the
1.87 wiz 8516: <code class="filename">../../textproc/intltool/buildlink3.mk</code> file,
8517: which forces it to use the intltool package provided by pkgsrc,
8518: instead of the one bundled with the distribution file.</p>
1.75 rillig 8519: <p>This tracks intltool's build-time dependencies and uses the
1.87 wiz 8520: latest available version; this way, the package benefits of any
8521: bug fixes that may have appeared since it was released.</p>
1.75 rillig 8522: </div>
8523: <div class="sect2" lang="en">
8524: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8525: <a name="startup-scripts"></a>18.6.15. Packages installing startup scripts</h3></div></div></div>
1.75 rillig 8526: <p>If a package contains a rc.d script, it won't be copied into
1.87 wiz 8527: the startup directory by default, but you can enable it, by adding
8528: the option <code class="varname">PKG_RCD_SCRIPTS=YES</code> in
8529: <code class="filename">/etc/mk.conf</code>. This option will copy the scripts
8530: into <code class="filename">/etc/rc.d</code> when a package is installed, and
8531: it will automatically remove the scripts when the package is
8532: deinstalled.</p>
1.75 rillig 8533: </div>
8534: <div class="sect2" lang="en">
8535: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8536: <a name="tex-packages"></a>18.6.16. Packages installing TeX modules</h3></div></div></div>
1.75 rillig 8537: <p>If a package installs TeX packages into the texmf tree,
1.87 wiz 8538: the <code class="filename">ls-R</code> database of the tree needs to be
8539: updated.</p>
1.75 rillig 8540: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
8541: <h3 class="title">Note</h3>
8542: <p>Except the main TeX packages such as teTeX-texmf,
1.87 wiz 8543: packages should install files
8544: into <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
8545: not <code class="varname">PKG_TEXMFPREFIX</code>.</p>
1.75 rillig 8546: </div>
8547: <div class="orderedlist"><ol type="1">
8548: <li><p>Include
1.87 wiz 8549: <code class="filename">../../print/teTeX/module.mk</code> instead
8550: of <code class="filename">../../mk/tex.buildlink3.mk</code>. This
8551: takes care of rebuilding the <code class="filename">ls-R</code>
8552: database at installation and deinstallation time.</p></li>
1.75 rillig 8553: <li>
8554: <p>If your package installs files into a texmf
1.87 wiz 8555: tree other than the one
8556: at <code class="varname">PKG_LOCALTEXMFPREFIX</code>,
8557: set <code class="varname">TEXMFDIRS</code> to the list of all texmf
8558: trees that need database update.</p>
1.75 rillig 8559: <p>If your package also installs font map files that need
1.87 wiz 8560: to be registered using <span><strong class="command">updmap</strong></span>,
8561: set <code class="varname">TEX_FONTMAPS</code> to the list of all
8562: such font map files. Then <span><strong class="command">updmap</strong></span> will
8563: be run automatically at installation/deinstallation to
8564: enable/disable font map files for TeX output
8565: drivers.</p>
1.75 rillig 8566: </li>
1.76 rillig 8567: <li><p>Make sure that none of <code class="filename">ls-R</code>
1.87 wiz 8568: databases are included in <code class="filename">PLIST</code>, as
8569: they will be removed only by the teTeX-bin package.</p></li>
1.75 rillig 8570: </ol></div>
8571: </div>
1.85 jmmv 8572: <div class="sect2" lang="en">
8573: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8574: <a name="emulation-packages"></a>18.6.17. Packages supporting running binaries in
1.87 wiz 8575: emulation</h3></div></div></div>
8576: <p>There are some packages that provide libraries and
8577: executables for running binaries from a one operating system
8578: on a different one (if the latter supports it). One example
8579: is running Linux binaries on NetBSD.</p>
8580: <p>The <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/rpm2pkg/README.html" target="_top"><code class="filename">pkgtools/rpm2pkg</code></a>
8581: helps in extracting and packaging Linux rpm packages.</p>
8582: <p>The <code class="varname">CHECK_SHLIBS</code> can be set to no to
8583: avoid the <span><strong class="command">check-shlibs</strong></span> target, which tests
8584: if all libraries for each installed executable can be found by
8585: the dynamic linker. Since the standard dynamic linker is run,
8586: this fails for emulation packages, because the libraries used
8587: by the emulation are not in the standard directories.</p>
8588: </div>
8589: <div class="sect2" lang="en">
8590: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8591: <a name="hicolor-theme"></a>18.6.18. Packages installing hicolor theme icons</h3></div></div></div>
1.85 jmmv 8592: <p>If a package installs images under the
1.87 wiz 8593: <code class="filename">share/icons/hicolor</code> and/or updates the
8594: <code class="filename">share/icons/hicolor/icon-theme.cache</code>
8595: database, you need to take some extra steps to make sure that the
8596: shared theme directory is handled appropriately and that the cache
8597: database is rebuilt:</p>
1.85 jmmv 8598: <div class="orderedlist"><ol type="1">
8599: <li><p>Include
1.87 wiz 8600: <code class="filename">../../graphics/hicolor-icon-theme/buildlink3.mk</code>.</p></li>
8601: <li><p>Check the <code class="filename">PLIST</code> and remove the
8602: entry that refers to the theme cache.</p></li>
1.85 jmmv 8603: <li><p>Ensure that the PLIST does not remove the shared icon
8604: directories from the <code class="filename">share/icons/hicolor</code>
8605: hierarchy because they will be handled automatically.</p></li>
8606: </ol></div>
8607: <p>The best way to verify that the PLIST is correct with
8608: respect to the last two points is to regenerate it using
8609: <span><strong class="command">make print-PLIST</strong></span>.</p>
8610: </div>
8611: <div class="sect2" lang="en">
8612: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 8613: <a name="desktop-files"></a>18.6.19. Packages installing desktop files</h3></div></div></div>
1.85 jmmv 8614: <p>If a package installs <code class="filename">.desktop</code> files
8615: under <code class="filename">share/applications</code> and these include
8616: MIME information, you need to take extra steps to ensure that they
8617: are registered into the MIME database:</p>
8618: <div class="orderedlist"><ol type="1">
8619: <li><p>Include
8620: <code class="filename">../../sysutils/desktop-file-utils/desktopdb.mk</code>.</p></li>
8621: <li><p>Check the PLIST and remove the entry that refers to the
8622: <code class="filename">share/applications/mimeinfo.cache</code> file.
8623: It will be handled automatically.</p></li>
8624: </ol></div>
8625: <p>The best way to verify that the PLIST is correct with
8626: respect to the last point is to regenerate it using <span><strong class="command">make
8627: print-PLIST</strong></span>.</p>
1.75 rillig 8628: </div>
8629: </div>
1.87 wiz 8630: <div class="sect1" lang="en">
8631: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 8632: <a name="punting"></a>18.7. Marking packages as having problems</h2></div></div></div>
1.87 wiz 8633: <p>In some cases one does not have the time to solve a problem
8634: immediately. There are currently two ways to declare that one knows
8635: that a package has problems.</p>
8636: <div class="itemizedlist"><ul type="disc">
8637: <li><p>The first way is to plainly mark it as broken. For
8638: this, one just sets the variable <code class="varname">BROKEN</code> to the
8639: reason why the package is broken (similar to the
8640: <code class="varname">RESTRICTED</code> variable). A user trying to build
8641: the package will immediately be shown this message, and the build
8642: will not be even tried.</p></li>
8643: <li><p>After each pkgsrc freeze period (a time when the
8644: tree is stabilized and a new pkgsrc branch is cut), the packages
8645: that were not building in the official branch build on the latest
8646: NetBSD release will be marked as broken on that branch. This is
8647: done by setting the <code class="varname">BROKEN_IN</code> variable to the
8648: branch name (or appending the branch name to it). If a user tries
8649: to build such a package and the build fails, the user gets a
8650: message that says that the package was broken on the respective
8651: branch(es).</p></li>
8652: </ul></div>
8653: <p>Both types of packages are removed from pkgsrc in irregular
8654: intervals.</p>
8655: </div>
1.75 rillig 8656: </div>
8657: <div class="chapter" lang="en">
8658: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 8659: <a name="debug"></a>Chapter 19. Debugging</h2></div></div></div>
1.88 wiz 8660: <p>To check out all the gotchas when building a package, here are
8661: the steps that I do in order to get a package working. Please note
8662: this is basically the same as what was explained in the previous
8663: sections, only with some debugging aids.</p>
1.75 rillig 8664: <div class="itemizedlist"><ul type="disc">
1.88 wiz 8665: <li><p>Be sure to set <code class="varname">PKG_DEVELOPER=1</code> in
8666: <code class="filename">/etc/mk.conf</code></p></li>
1.75 rillig 8667: <li>
1.76 rillig 8668: <p>Install <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/url2pkg/README.html" target="_top"><code class="filename">pkgtools/url2pkg</code></a>,
1.88 wiz 8669: create a directory for a new package, change into it, then run
8670: <span><strong class="command">url2pkg</strong></span>:</p>
1.75 rillig 8671: <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>
8672: <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>
8673: <code class="prompt">%</code> <strong class="userinput"><code>url2pkg http://www.example.com/path/to/distfile.tar.gz</code></strong></pre>
8674: </li>
1.76 rillig 8675: <li><p>Edit the <code class="filename">Makefile</code> as requested.</p></li>
8676: <li><p>Fill in the <code class="filename">DESCR</code> file</p></li>
1.87 wiz 8677: <li><p>Run <span><strong class="command">make configure</strong></span></p></li>
1.75 rillig 8678: <li><p>Add any dependencies glimpsed from documentation and the
1.88 wiz 8679: configure step to the package's
8680: <code class="filename">Makefile</code>.</p></li>
1.75 rillig 8681: <li>
8682: <p>Make the package compile, doing multiple rounds of</p>
8683: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
8684: <code class="prompt">%</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
8685: <code class="prompt">%</code> <strong class="userinput"><code>mkpatches</code></strong>
8686: <code class="prompt">%</code> <strong class="userinput"><code>patchdiff</code></strong>
8687: <code class="prompt">%</code> <strong class="userinput"><code>mv ${WRKDIR}/.newpatches/* patches</code></strong>
8688: <code class="prompt">%</code> <strong class="userinput"><code>make mps</code></strong>
8689: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong></pre>
1.88 wiz 8690: <p>Doing this step as non-root user will ensure that no files
8691: are modified that shouldn't be, especially during the build
8692: phase. <span><strong class="command">mkpatches</strong></span>,
8693: <span><strong class="command">patchdiff</strong></span> and <span><strong class="command">pkgvi</strong></span> are
8694: from the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkgdiff/README.html" target="_top"><code class="filename">pkgtools/pkgdiff</code></a>
8695: package.</p>
1.75 rillig 8696: </li>
1.88 wiz 8697: <li><p>Look at the <code class="filename">Makefile</code>, fix if
1.90 ! rillig 8698: necessary; see <a href="#components.Makefile" title="10.1. Makefile">Section 10.1, “<code class="filename">Makefile</code>”</a>.</p></li>
1.75 rillig 8699: <li>
1.76 rillig 8700: <p>Generate a <code class="filename">PLIST</code>:</p>
1.75 rillig 8701: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
8702: <code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST >PLIST</code></strong>
8703: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong>
8704: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
8705: <code class="prompt">#</code> <strong class="userinput"><code>make deinstall</code></strong></pre>
1.88 wiz 8706: <p>You usually need to be <code class="username">root</code> to do
8707: this. Look if there are any files left:</p>
1.75 rillig 8708: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
8709: <p>If this reveals any files that are missing in
1.88 wiz 8710: <code class="filename">PLIST</code>, add them.</p>
1.75 rillig 8711: </li>
8712: <li>
1.88 wiz 8713: <p>Now that the <code class="filename">PLIST</code> is OK, install the
8714: package again and make a binary package:</p>
1.75 rillig 8715: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make reinstall</code></strong>
8716: <code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong></pre>
8717: </li>
8718: <li>
8719: <p>Delete the installed package:</p>
1.88 wiz 8720: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_delete <em class="replaceable"><code>examplepkg</code></em></code></strong></pre>
1.75 rillig 8721: </li>
8722: <li>
1.88 wiz 8723: <p>Repeat the above <span><strong class="command">make print-PLIST</strong></span>
8724: command, which shouldn't find anything now:</p>
1.75 rillig 8725: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make print-PLIST</code></strong></pre>
8726: </li>
8727: <li>
8728: <p>Reinstall the binary package:</p>
1.88 wiz 8729: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkgadd .../<em class="replaceable"><code>examplepkg</code></em>.tgz</code></strong></pre>
1.75 rillig 8730: </li>
1.88 wiz 8731: <li><p>Play with it. Make sure everything works.</p></li>
1.75 rillig 8732: <li>
1.88 wiz 8733: <p>Run <span><strong class="command">pkglint</strong></span> from <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>, and fix the problems it
8734: reports:</p>
1.75 rillig 8735: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkglint</code></strong></pre>
8736: </li>
1.90 ! rillig 8737: <li><p>Submit (or commit, if you have cvs access); see <a href="#submit" title="Chapter 20. Submitting and Committing">Chapter 20, <i>Submitting and Committing</i></a>.</p></li>
1.75 rillig 8738: </ul></div>
8739: </div>
8740: <div class="chapter" lang="en">
8741: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 8742: <a name="submit"></a>Chapter 20. Submitting and Committing</h2></div></div></div>
1.75 rillig 8743: <div class="toc">
8744: <p><b>Table of Contents</b></p>
8745: <dl>
1.90 ! rillig 8746: <dt><span class="sect1"><a href="#submitting-binary-packages">20.1. Submitting binary packages</a></span></dt>
! 8747: <dt><span class="sect1"><a href="#submitting-your-package">20.2. Submitting source packages (for non-NetBSD-developers)</a></span></dt>
! 8748: <dt><span class="sect1"><a href="#general-notes-for-changes">20.3. General notes when adding, updating, or removing packages</a></span></dt>
! 8749: <dt><span class="sect1"><a href="#committing-importing">20.4. Committing: Importing a package into CVS</a></span></dt>
! 8750: <dt><span class="sect1"><a href="#updating-package">20.5. Updating a package to a newer version</a></span></dt>
! 8751: <dt><span class="sect1"><a href="#moving-package">20.6. Moving a package in pkgsrc</a></span></dt>
1.75 rillig 8752: </dl>
8753: </div>
8754: <div class="sect1" lang="en">
8755: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 8756: <a name="submitting-binary-packages"></a>20.1. Submitting binary packages</h2></div></div></div>
1.75 rillig 8757: <p>Our policy is that we accept binaries only from pkgsrc
8758: developers to guarantee that the packages don't contain any
8759: trojan horses etc. This is not to annoy anyone but rather to
8760: protect our users! You're still free to put up your home-made
8761: binary packages and tell the world where to get them. NetBSD
8762: developers doing bulk builds and wanting to upload them please
8763: see <a href="#bulk-upload" title="6.3.8. Uploading results of a bulk build">Section 6.3.8, “Uploading results of a bulk build”</a>.</p>
8764: </div>
8765: <div class="sect1" lang="en">
8766: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 8767: <a name="submitting-your-package"></a>20.2. Submitting source packages (for non-NetBSD-developers)</h2></div></div></div>
1.75 rillig 8768: <p>First, check that your package is complete, compiles and
1.90 ! rillig 8769: runs well; see <a href="#debug" title="Chapter 19. Debugging">Chapter 19, <i>Debugging</i></a> and the rest of this
1.75 rillig 8770: document. Next, generate an uuencoded gzipped <a href="http://netbsd.gw.com/cgi-bin/man-cgi?tar+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">tar</span>(1)</span></a>
1.82 rillig 8771: archive that contains all files that make up the package.
1.87 wiz 8772: Finally, send this package to the pkgsrc bug tracking system,
8773: either with the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?send-pr+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">send-pr</span>(1)</span></a> command, or if you don't have
8774: that, go to the web page
8775: <a href="http://www.NetBSD.org/Misc/send-pr.html" target="_top">http://www.NetBSD.org/Misc/send-pr.html</a>,
8776: which contains some instructions and a link to a form, where you
8777: can submit packages.</p>
8778: <p>In the form of the problem report, the category should be
8779: “<span class="quote">pkg</span>”, the synopsis should include the package name
8780: and version number, and the description field should contain a
8781: short description of your package (contents of the COMMENT
8782: variable or DESCR file are OK). The uuencoded package data should
8783: go into the “<span class="quote">fix</span>” field.</p>
1.75 rillig 8784: <p>If you want to submit several packages, please send a
8785: separate PR for each one, it's easier for us to track things
8786: that way.</p>
8787: <p>Alternatively, you can also import new packages into
8788: pkgsrc-wip (“<span class="quote">pkgsrc work-in-progress</span>”); see the
8789: homepage at <a href="http://pkgsrc-wip.sourceforge.net/" target="_top">http://pkgsrc-wip.sourceforge.net/</a>
8790: for details.</p>
8791: </div>
8792: <div class="sect1" lang="en">
8793: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 8794: <a name="general-notes-for-changes"></a>20.3. General notes when adding, updating, or removing packages</h2></div></div></div>
1.75 rillig 8795: <p>Please note all package additions, updates, moves, and
1.76 rillig 8796: removals in <code class="filename">pkgsrc/doc/CHANGES</code>. It's very
1.75 rillig 8797: important to keep this file up to date and conforming to the
8798: existing format, because it will be used by scripts to
8799: automatically update pages on <a href="http://www.NetBSD.org/" target="_top">www.NetBSD.org</a> and other
8800: sites. Additionally, check the
1.76 rillig 8801: <code class="filename">pkgsrc/doc/TODO</code> file and remove the entry
1.75 rillig 8802: for the package you updated or removed, in case it was mentioned
8803: there.</p>
8804: <p>When the <code class="varname">PKGREVISION</code> of a package is
8805: bumped, the change should appear in
1.76 rillig 8806: <code class="filename">pkgsrc/doc/CHANGES</code> if it is security
1.75 rillig 8807: related or otherwise relevant. Mass bumps that result from a
8808: dependency being updated should not be mentioned. In all other
8809: cases it's the developer's decision.</p>
8810: <p>There is a make target that helps in creating proper
1.76 rillig 8811: <code class="filename">CHANGES</code> entries: <span><strong class="command">make
1.75 rillig 8812: changes-entry</strong></span>. It uses the optional <code class="varname">CTYPE</code>
8813: and <code class="varname">NETBSD_LOGIN_NAME</code> variables. The general
1.76 rillig 8814: usage is to first make sure that your <code class="filename">CHANGES</code>
1.75 rillig 8815: file is up-to-date (to avoid having to resolve conflicts later-on)
8816: and then to <span><strong class="command">cd</strong></span> to the package directory. For
8817: package updates, <span><strong class="command">make changes-entry</strong></span> is enough.
8818: For new packages, or package moves or removals, set the
8819: <code class="varname">CTYPE</code> variable on the command line to "Added",
8820: "Moved", or "Removed". You can set <code class="varname">NETBSD_LOGIN_NAME</code>
1.76 rillig 8821: in <code class="filename">/etc/mk.conf</code> if your local login name is
1.75 rillig 8822: not the same as your NetBSD login name. Don't forget to commit
1.76 rillig 8823: the changes to <code class="filename">pkgsrc/doc/CHANGES</code>!</p>
1.75 rillig 8824: </div>
8825: <div class="sect1" lang="en">
8826: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 8827: <a name="committing-importing"></a>20.4. Committing: Importing a package into CVS</h2></div></div></div>
1.87 wiz 8828: <p>This section is only of interest for pkgsrc developers with write
1.75 rillig 8829: access to the pkgsrc repository. Please remember that cvs
8830: imports files relative to the current working directory, and that
8831: the pathname that you
8832: give the <span><strong class="command">cvs import</strong></span> command is so that it knows where
8833: to place the files in the repository. Newly created packages should be
8834: imported with a vendor tag of “<span class="quote">TNF</span>” and a release tag of
1.87 wiz 8835: “<span class="quote">pkgsrc-base</span>”, e.g:</p>
1.75 rillig 8836: <pre class="programlisting">
8837: <code class="prompt">$</code> cd .../pkgsrc/category/pkgname
8838: <code class="prompt">$</code> cvs import pkgsrc/category/pkgname TNF pkgsrc-base
8839: </pre>
1.87 wiz 8840: <p>Remember to move the directory from which you imported out of
1.75 rillig 8841: the way, or cvs will complain the next time you “<span class="quote">cvs
8842: update</span>” your source tree. Also don't forget to add the new
1.87 wiz 8843: package to the category's <code class="filename">Makefile</code>.</p>
8844: <p>The commit message of the initial import should include part of the
1.76 rillig 8845: <code class="filename">DESCR</code> file, so people reading the mailing lists know
1.87 wiz 8846: what the package is/does.</p>
8847: <p>For new packages, “<span class="quote">cvs import</span>” is preferred to “<span class="quote">cvs
1.75 rillig 8848: add</span>” because the former gets everything with a single command,
1.87 wiz 8849: and provides a consistent tag.</p>
1.75 rillig 8850: </div>
8851: <div class="sect1" lang="en">
8852: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 8853: <a name="updating-package"></a>20.5. Updating a package to a newer version</h2></div></div></div>
1.87 wiz 8854: <p>Please always put a concise, appropriate and relevant summary of the
1.75 rillig 8855: changes between old and new versions into the commit log when updating
1.87 wiz 8856: a package. There are various reasons for this:</p>
1.75 rillig 8857: <div class="itemizedlist"><ul type="disc">
1.87 wiz 8858: <li><p>A URL is volatile, and can change over time. It may go away completely
8859: or its information may be overwritten by newer information.</p></li>
8860: <li><p>Having the change information between old and new versions in our CVS
8861: repository is very useful for people who use either cvs or anoncvs.</p></li>
8862: <li><p>Having the change information between old and new versions in our CVS
1.75 rillig 8863: repository is very useful for people who read the pkgsrc-changes mailing
8864: list, so that they can make tactical decisions about when to upgrade
1.87 wiz 8865: the package.</p></li>
1.75 rillig 8866: </ul></div>
1.87 wiz 8867: <p>Please also recognize that, just because a new version of a package
1.75 rillig 8868: has been released, it should not automatically be upgraded in the CVS
8869: repository. We prefer to be conservative in the packages that are
8870: included in pkgsrc - development or beta packages are not really the
8871: best thing for most places in which pkgsrc is used. Please use your
8872: judgement about what should go into pkgsrc, and bear in mind that
1.87 wiz 8873: stability is to be preferred above new and possibly untested features.</p>
1.75 rillig 8874: </div>
8875: <div class="sect1" lang="en">
8876: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 8877: <a name="moving-package"></a>20.6. Moving a package in pkgsrc</h2></div></div></div>
1.75 rillig 8878: <div class="orderedlist"><ol type="1">
8879: <li><p>Make a copy of the directory somewhere else.</p></li>
8880: <li>
8881: <p>Remove all CVS dirs.</p>
1.87 wiz 8882: <p>Alternatively to the first two steps you can also do:</p>
1.75 rillig 8883: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package</code></strong></pre>
1.87 wiz 8884: <p>and use that for further work.</p>
1.75 rillig 8885: </li>
8886: <li><p>Fix <code class="varname">CATEGORIES</code> and any
8887: <code class="varname">DEPENDS</code> paths that just did “<span class="quote">../package</span>”
8888: instead of “<span class="quote">../../category/package</span>”.</p></li>
8889: <li><p><span><strong class="command">cvs import</strong></span> the modified package in the new
8890: place.</p></li>
8891: <li>
8892: <p>Check if any package depends on it:
8893: </p>
8894: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
8895: <code class="prompt">%</code> <strong class="userinput"><code>grep /package */*/Makefile* */*/buildlink*</code></strong></pre>
8896: </li>
8897: <li><p>Fix paths in packages from step 5 to point to new location.</p></li>
8898: <li><p><span><strong class="command">cvs rm (-f)</strong></span> the package at the old location.</p></li>
1.76 rillig 8899: <li><p>Remove from <code class="filename">oldcategory/Makefile</code>.</p></li>
8900: <li><p>Add to <code class="filename">newcategory/Makefile</code>.</p></li>
1.75 rillig 8901: <li>
8902: <p>Commit the changed and removed files:</p>
8903: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile</code></strong></pre>
1.87 wiz 8904: <p>(and any packages from step 5, of course).</p>
1.75 rillig 8905: </li>
8906: </ol></div>
8907: </div>
8908: </div>
8909: <div class="chapter" lang="en">
8910: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 8911: <a name="devfaq"></a>Chapter 21. Frequently Asked Questions</h2></div></div></div>
1.75 rillig 8912: <p>This section contains the answers to questions that may
8913: arise when you are writing a package. If you don't find your
8914: question answered here, first have a look in the other chapters,
8915: and if you still don't have the answer, ask on the
8916: <code class="literal">pkgsrc-users</code> mailing list.</p>
8917: <div class="qandaset">
8918: <dl>
1.90 ! rillig 8919: <dt>21.1. <a href="#id2658401">What is the difference between
1.75 rillig 8920: MAKEFLAGS, .MAKEFLAGS and
8921: MAKE_FLAGS?</a>
8922: </dt>
1.90 ! rillig 8923: <dt>21.2. <a href="#id2658437">What is the difference between
1.75 rillig 8924: MAKE, GMAKE and
8925: MAKE_PROGRAM?</a>
8926: </dt>
1.90 ! rillig 8927: <dt>21.3. <a href="#id2658475">What is the difference between
1.75 rillig 8928: CC, PKG_CC and
8929: PKGSRC_COMPILER?</a>
8930: </dt>
1.90 ! rillig 8931: <dt>21.4. <a href="#id2658581">What is the difference between
1.75 rillig 8932: BUILDLINK_LDFLAGS,
8933: BUILDLINK_LDADD and
8934: BUILDLINK_LIBS?</a>
8935: </dt>
1.90 ! rillig 8936: <dt>21.5. <a href="#id2658599">Why does make show-var
1.75 rillig 8937: VARNAME=BUILDLINK_PREFIX.foo
8938: say it's empty?</a>
8939: </dt>
1.90 ! rillig 8940: <dt>21.6. <a href="#id2658627">What does
1.78 rillig 8941: ${MASTER_SITE_SOURCEFORGE:=package/} mean? I
8942: don't understand the := inside
8943: it.</a>
8944: </dt>
1.90 ! rillig 8945: <dt>21.7. <a href="#id2658701">Which mailing lists are there for package
1.78 rillig 8946: developers?</a>
8947: </dt>
1.90 ! rillig 8948: <dt>21.8. <a href="#id2658738">Where is the pkgsrc
1.80 rillig 8949: documentation?</a>
8950: </dt>
1.75 rillig 8951: </dl>
8952: <table border="0" summary="Q and A Set">
8953: <col align="left" width="1%">
8954: <tbody>
8955: <tr class="question">
8956: <td align="left" valign="top">
1.90 ! rillig 8957: <a name="id2658401"></a><a name="id2658402"></a><b>21.1.</b>
1.75 rillig 8958: </td>
8959: <td align="left" valign="top"><p>What is the difference between
8960: <code class="varname">MAKEFLAGS</code>, <code class="varname">.MAKEFLAGS</code> and
8961: <code class="varname">MAKE_FLAGS</code>?</p></td>
8962: </tr>
8963: <tr class="answer">
1.89 rillig 8964: <td align="left" valign="top"><b></b></td>
1.75 rillig 8965: <td align="left" valign="top"><p><code class="varname">MAKEFLAGS</code> are the flags passed
8966: to the pkgsrc-internal invocations of <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>, while
8967: <code class="varname">MAKE_FLAGS</code> are the flags that are passed to
8968: the <code class="varname">MAKE_PROGRAM</code> when building the
8969: package. [FIXME: What is .MAKEFLAGS for?]</p></td>
8970: </tr>
8971: <tr class="question">
8972: <td align="left" valign="top">
1.90 ! rillig 8973: <a name="id2658437"></a><a name="id2658438"></a><b>21.2.</b>
1.75 rillig 8974: </td>
8975: <td align="left" valign="top"><p>What is the difference between
8976: <code class="varname">MAKE</code>, <code class="varname">GMAKE</code> and
8977: <code class="varname">MAKE_PROGRAM</code>?</p></td>
8978: </tr>
8979: <tr class="answer">
1.89 rillig 8980: <td align="left" valign="top"><b></b></td>
1.75 rillig 8981: <td align="left" valign="top"><p><code class="varname">MAKE</code> is the path to the
8982: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> program that is used in the pkgsrc
8983: infrastructure. <code class="varname">GMAKE</code> is the path to GNU
8984: Make, but you need to say <code class="varname">USE_TOOLS+=gmake</code> to
8985: use that. <code class="varname">MAKE_PROGRAM</code> is the path to the
8986: Make program that is used for building the
8987: package.</p></td>
8988: </tr>
8989: <tr class="question">
8990: <td align="left" valign="top">
1.90 ! rillig 8991: <a name="id2658475"></a><a name="id2658476"></a><b>21.3.</b>
1.75 rillig 8992: </td>
8993: <td align="left" valign="top"><p>What is the difference between
8994: <code class="varname">CC</code>, <code class="varname">PKG_CC</code> and
8995: <code class="varname">PKGSRC_COMPILER</code>?</p></td>
8996: </tr>
8997: <tr class="answer">
1.89 rillig 8998: <td align="left" valign="top"><b></b></td>
1.75 rillig 8999: <td align="left" valign="top"><p><code class="varname">CC</code> is the path to the real C
9000: compiler, which can be configured by the pkgsrc user.
9001: <code class="varname">PKG_CC</code> is the path to the compiler wrapper.
9002: <code class="varname">PKGSRC_COMPILER</code> is <span class="emphasis"><em>not</em></span> a
9003: path to a compiler, but the type of compiler that should be
1.76 rillig 9004: used. See <code class="filename">mk/compiler.mk</code> for more
1.75 rillig 9005: information about the latter variable.</p></td>
9006: </tr>
9007: <tr class="question">
9008: <td align="left" valign="top">
1.90 ! rillig 9009: <a name="id2658581"></a><a name="id2658582"></a><b>21.4.</b>
1.75 rillig 9010: </td>
9011: <td align="left" valign="top"><p>What is the difference between
9012: <code class="varname">BUILDLINK_LDFLAGS</code>,
9013: <code class="varname">BUILDLINK_LDADD</code> and
9014: <code class="varname">BUILDLINK_LIBS</code>?</p></td>
9015: </tr>
9016: <tr class="answer">
1.89 rillig 9017: <td align="left" valign="top"><b></b></td>
1.75 rillig 9018: <td align="left" valign="top"><p>[FIXME]</p></td>
9019: </tr>
9020: <tr class="question">
9021: <td align="left" valign="top">
1.90 ! rillig 9022: <a name="id2658599"></a><a name="id2658600"></a><b>21.5.</b>
1.75 rillig 9023: </td>
9024: <td align="left" valign="top"><p>Why does <span><strong class="command">make show-var
9025: VARNAME=BUILDLINK_PREFIX.<em class="replaceable"><code>foo</code></em></strong></span>
9026: say it's empty?</p></td>
9027: </tr>
9028: <tr class="answer">
1.89 rillig 9029: <td align="left" valign="top"><b></b></td>
1.75 rillig 9030: <td align="left" valign="top"><p>For optimization reasons, some variables are only
9031: available in the “<span class="quote">wrapper</span>” phase and later. To
9032: “<span class="quote">simulate</span>” the wrapper phase, append
9033: <span><strong class="command">PKG_PHASE=wrapper</strong></span> to the above
9034: command.</p></td>
9035: </tr>
1.78 rillig 9036: <tr class="question">
9037: <td align="left" valign="top">
1.90 ! rillig 9038: <a name="id2658627"></a><a name="id2658628"></a><b>21.6.</b>
1.78 rillig 9039: </td>
9040: <td align="left" valign="top"><p>What does
9041: <code class="literal">${MASTER_SITE_SOURCEFORGE:=package/}</code> mean? I
9042: don't understand the <code class="literal">:=</code> inside
9043: it.</p></td>
9044: </tr>
9045: <tr class="answer">
1.89 rillig 9046: <td align="left" valign="top"><b></b></td>
1.78 rillig 9047: <td align="left" valign="top"><p>The <code class="literal">:=</code> is not really an
9048: assignment operator, like you might expect at first sight.
9049: Instead, it is a degenerate form of
9050: <code class="literal">${LIST:<em class="replaceable"><code>old_string</code></em>=<em class="replaceable"><code>new_string</code></em>}</code>,
9051: which is documented in the <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> man page and which you
9052: may have seen as in <code class="literal">${SRCS:.c=.o}</code>. In the
9053: case of <code class="varname">MASTER_SITE_*</code>,
9054: <em class="replaceable"><code>old_string</code></em> is the empty string and
9055: <em class="replaceable"><code>new_string</code></em> is
9056: <code class="literal">package/</code>. That's where the
9057: <code class="literal">:</code> and the <code class="literal">=</code> fall
9058: together.</p></td>
9059: </tr>
9060: <tr class="question">
9061: <td align="left" valign="top">
1.90 ! rillig 9062: <a name="id2658701"></a><a name="id2658702"></a><b>21.7.</b>
1.78 rillig 9063: </td>
9064: <td align="left" valign="top"><p>Which mailing lists are there for package
9065: developers?</p></td>
9066: </tr>
9067: <tr class="answer">
1.89 rillig 9068: <td align="left" valign="top"><b></b></td>
1.78 rillig 9069: <td align="left" valign="top"><div class="variablelist"><dl>
9070: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#tech-pkg" target="_top">tech-pkg</a></span></dt>
9071: <dd><p>This is a list for technical discussions related
9072: to pkgsrc development, e.g. soliciting feedback for changes to
9073: pkgsrc infrastructure, proposed new features, questions related
9074: to porting pkgsrc to a new platform, advice for maintaining a
9075: package, patches that affect many packages, help requests moved
9076: from pkgsrc-users when an infrastructure bug is found,
9077: etc.</p></dd>
9078: <dt><span class="term"><a href="http://www.NetBSD.org/MailingLists/index.html#pkgsrc-bugs" target="_top">pkgsrc-bugs</a></span></dt>
9079: <dd><p>All bug reports in category "pkg" sent with
9080: <a href="http://netbsd.gw.com/cgi-bin/man-cgi?send-pr+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">send-pr</span>(1)</span></a> appear here. Please do not report your bugs here
9081: directly; use one of the other mailing
9082: lists.</p></dd>
9083: </dl></div></td>
9084: </tr>
1.80 rillig 9085: <tr class="question">
9086: <td align="left" valign="top">
1.90 ! rillig 9087: <a name="id2658738"></a><a name="id2658739"></a><b>21.8.</b>
1.80 rillig 9088: </td>
9089: <td align="left" valign="top"><p>Where is the pkgsrc
9090: documentation?</p></td>
9091: </tr>
9092: <tr class="answer">
1.89 rillig 9093: <td align="left" valign="top"><b></b></td>
1.80 rillig 9094: <td align="left" valign="top">
9095: <p>There are many places where you can find
9096: documentation about pkgsrc:</p>
9097: <div class="itemizedlist"><ul type="disc">
9098: <li><p>The pkgsrc guide (this document) is a collection
9099: of chapters that explain large parts of pkgsrc, but some
9100: chapters tend to be outdated. Which ones they are is hard to
9101: say.</p></li>
9102: <li><p>On the mailing list archives (see <a href="http://mail-index.NetBSD.org/" target="_top">http://mail-index.NetBSD.org/</a>), you can find discussions
9103: about certain features, announcements of new parts of the pkgsrc
9104: infrastructure and sometimes even announcements that a certain
9105: feature has been marked as obsolete. The benefit here is that
9106: each message has a date appended to it.</p></li>
9107: <li><p>Many of the files in the
9108: <code class="filename">mk/</code> directory start with a comment that
9109: describes the purpose of the file and how it can be used by the
9110: pkgsrc user and package authors.</p></li>
9111: <li><p>The CVS log messages are a rich source of
9112: information, but they tend to be highly abbreviated, especially
9113: for actions that occur often. Some contain a detailed
9114: description of what has changed, but they are geared towards the
9115: other pkgsrc developers, not towards an average pkgsrc user.
9116: They also only document <span class="emphasis"><em>changes</em></span>, so if you
9117: don't know what has been before, these messages may not be worth
9118: too much to you.</p></li>
9119: <li><p>Some parts of pkgsrc are only “<span class="quote">implicitly
9120: documented</span>”, that is the documentation exists only in the
9121: mind of the developer who wrote the code. To get this
9122: information, use the the <span><strong class="command">cvs annotate</strong></span> command
9123: to see who has written it and ask on the
9124: <code class="literal">tech-pkg</code> mailing list, so that others can
9125: find your questions later (see above). To be sure that the
9126: developer in charge reads the mail, you may CC him or
9127: her.</p></li>
9128: </ul></div>
9129: </td>
9130: </tr>
1.75 rillig 9131: </tbody>
9132: </table>
9133: </div>
9134: </div>
1.85 jmmv 9135: <div class="chapter" lang="en">
9136: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 9137: <a name="gnome"></a>Chapter 22. GNOME packaging and porting</h2></div></div></div>
1.85 jmmv 9138: <div class="toc">
9139: <p><b>Table of Contents</b></p>
9140: <dl>
1.90 ! rillig 9141: <dt><span class="sect1"><a href="#meta-packages">22.1. Meta packages</a></span></dt>
! 9142: <dt><span class="sect1"><a href="#new-package">22.2. Packaging a GNOME application</a></span></dt>
! 9143: <dt><span class="sect1"><a href="#full-update">22.3. Updating GNOME to a newer version</a></span></dt>
! 9144: <dt><span class="sect1"><a href="#patching">22.4. Patching guidelines</a></span></dt>
1.85 jmmv 9145: </dl>
9146: </div>
9147: <p>Quoting <a href="http://www.gnome.org/" target="_top">GNOME's web
9148: site</a>:</p>
9149: <div class="blockquote"><blockquote class="blockquote"><p>The GNOME project provides two things: The GNOME desktop
9150: environment, an intuitive and attractive desktop for users, and the
9151: GNOME development platform, an extensive framework for building
9152: applications that integrate into the rest of the desktop.</p></blockquote></div>
9153: <p>pkgsrc provides a seamless way to automatically build and install
9154: a complete GNOME environment <span class="emphasis"><em>under many different
9155: platforms</em></span>. We can say with confidence that pkgsrc is one of
9156: the most advanced build and packaging systems for GNOME due to its
9157: included technologies buildlink3, the wrappers and tools framework and
9158: automatic configuration file management. Lots of efforts are put into
9159: achieving a completely clean deinstallation of installed software
9160: components.</p>
9161: <p>Given that pkgsrc is <a href="http://www.NetBSD.org/" target="_top">NetBSD</a>'s official packaging system,
9162: the above also means that great efforts are put into making GNOME work
9163: under this operating system. Recently, <a href="http://www.dragonflybsd.org/" target="_top">DragonFly BSD</a> also adopted
9164: pkgsrc as its preferred packaging system, contributing lots of
9165: portability fixes to make GNOME build and install under it.</p>
9166: <p>This chapter is aimed at pkgsrc developers and other people
9167: interested in helping our GNOME porting and packaging efforts. It
9168: provides instructions on how to manage the existing packages and some
9169: important information regarding their internals.</p>
9170: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
9171: <h3 class="title">We need your help!</h3>
9172: <p>Should you have some spare cycles to devote to NetBSD, pkgsrc
9173: and GNOME and are willing to learn new exciting stuff, please jump
9174: straight to the <a href="http://www.NetBSD.org/contrib/projects.html#gnome" target="_top">pending
9175: work</a> list! There is still a long way to go to get a
9176: fully-functional GNOME desktop under NetBSD and we need your help to
9177: achieve it!</p>
9178: </div>
9179: <div class="sect1" lang="en">
9180: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9181: <a name="meta-packages"></a>22.1. Meta packages</h2></div></div></div>
1.85 jmmv 9182: <p>pkgsrc includes three GNOME-related meta packages:</p>
9183: <div class="itemizedlist"><ul type="disc">
9184: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome-base/README.html" target="_top"><code class="filename">meta-pkgs/gnome-base</code></a>: Provides
9185: the core GNOME desktop environment. It only includes the necessary
9186: bits to get it to boot correctly, although it may lack important
9187: functionality for daily operation. The idea behind this package is
9188: to let end users build their own configurations on top of this one,
9189: first installing this meta package to achieve a functional setup and
9190: then adding individual applications.</p></li>
9191: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome/README.html" target="_top"><code class="filename">meta-pkgs/gnome</code></a>: Provides a
9192: complete installation of the GNOME platform and desktop as defined
9193: by the GNOME project; this is based on the components distributed in
9194: the <code class="filename">platform/x.y/x.y.z/sources</code> and
9195: <code class="filename">desktop/x.y/x.y.z/sources</code> directories of the
9196: official FTP server. Developer-only tools found in those
9197: directories are not installed unless required by some other
9198: component to work properly. Similarly, packages from the bindings
9199: set (<code class="filename">bindings/x.y/x.y.z/sources</code>) are not pulled
9200: in unless required as a dependency for an end-user component. This
9201: package "extends" <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome-base/README.html" target="_top"><code class="filename">meta-pkgs/gnome-base</code></a>.</p></li>
9202: <li><p><a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome-devel/README.html" target="_top"><code class="filename">meta-pkgs/gnome-devel</code></a>:
9203: Installs all the tools required to build a GNOME component when
9204: fetched from the CVS repository. These are required to let the
9205: <span><strong class="command">autogen.sh</strong></span> scripts work appropriately.</p></li>
9206: </ul></div>
9207: <p>In all these packages, the <code class="varname">DEPENDS</code> lines are
9208: sorted in a way that eases updates: a package may depend on other
9209: packages listed before it but not on any listed after it. It is very
9210: important to keep this order to ease updates so... <span class="emphasis"><em>do not
9211: change it to alphabetical sorting!</em></span></p>
9212: </div>
9213: <div class="sect1" lang="en">
9214: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9215: <a name="new-package"></a>22.2. Packaging a GNOME application</h2></div></div></div>
1.85 jmmv 9216: <p>Almost all GNOME applications are written in C and use a common
9217: set of tools as their build system. Things get different with the new
9218: bindings to other languages (such as Python), but the following will
9219: give you a general idea on the minimum required tools:</p>
9220: <div class="itemizedlist"><ul type="disc">
9221: <li>
9222: <p>Almost all GNOME applications use the GNU Autotools as their
9223: build system. As a general rule you will need to tell this to your
9224: package:</p>
9225: <pre class="programlisting">GNU_CONFIGURE=yes
9226: USE_LIBTOOL=yes
9227: USE_TOOLS+=gmake</pre>
9228: </li>
9229: <li>
9230: <p>If the package uses pkg-config to detect dependencies, add this
9231: tool to the list of required utilities:</p>
9232: <pre class="programlisting">USE_TOOLS+=pkg-config</pre>
9233: <p>Also use <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/verifypc/README.html" target="_top"><code class="filename">pkgtools/verifypc</code></a> at
9234: the end of the build process to ensure that you did not miss to
9235: specify any dependency in your package and that the version
9236: requirements are all correct.</p>
9237: </li>
9238: <li><p>If the package uses intltool, be sure to include the <a href="http://cvsweb.NetBSD.org/bsdweb.cgi/pkgsrc/textproc/intltool/buildlink3.mk?rev=HEAD&content-type=text/x-cvsweb-markup" target="_top"><code class="filename">pkgsrc/textproc/intltool/buildlink3.mk</code></a> file
9239: to handle dependencies and to force the package to use the latest
9240: available version.</p></li>
9241: <li>
9242: <p>If the package uses gtk-doc (a documentation generation
9243: utility), do <span class="emphasis"><em>not</em></span> add a dependency on it. The
9244: tool is rather big and the distfile should come with pregenerated
9245: documentation anyway; if it does not, it is a bug that you ought to
9246: report. For such packages you should disable gtk-doc (unless it is
1.89 rillig 9247: the default):</p>
9248: <pre class="programlisting">CONFIGURE_ARGS+=--disable-gtk-doc</pre>
9249: <p>The default location of installed HTML files
9250: (<code class="filename">share/gtk-doc/<package-name></code>) is correct
9251: and should not be changed unless the package insists on installing
9252: them somewhere else. Otherwise programs as
9253: <span><strong class="command">devhelp</strong></span> will not be able to open them. You can
9254: do that with an entry similar to:</p>
9255: <pre class="programlisting">CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...</pre>
1.85 jmmv 9256: </li>
9257: </ul></div>
9258: <p>GNOME uses multiple <span class="emphasis"><em>shared</em></span> directories and
9259: files under the installation prefix to maintain databases. In this
9260: context, shared means that those exact same directories and files are
9261: used among several different packages, leading to conflicts in the
9262: <code class="filename">PLIST</code>. pkgsrc currently includes functionality to
9263: handle the most common cases, so you have to forget about using
9264: <code class="literal">@unexec ${RMDIR}</code> lines in your file lists and
9265: omitting shared files from them. If you find yourself doing those,
9266: <span class="emphasis"><em>your package is most likely incorrect</em></span>.</p>
9267: <p>The following table lists the common situations that result in
9268: using shared directories or files. For each of them, the appropriate
9269: solution is given. After applying the solution be sure to
9270: <span class="emphasis"><em>regenerate the package's file list</em></span> with
9271: <span><strong class="command">make print-PLIST</strong></span> and ensure it is correct.</p>
9272: <div class="table">
1.90 ! rillig 9273: <a name="plist-handling"></a><p class="title"><b>Table 22.1. PLIST handling for GNOME packages</b></p>
1.89 rillig 9274: <table summary="PLIST handling for GNOME packages" border="1">
1.85 jmmv 9275: <colgroup>
9276: <col>
9277: <col>
9278: </colgroup>
9279: <thead><tr>
9280: <th>If the package...</th>
9281: <th>Then...</th>
9282: </tr></thead>
9283: <tbody>
9284: <tr>
9285: <td>Installs OMF files under <code class="filename">share/omf</code>.</td>
1.90 ! rillig 9286: <td>See <a href="#scrollkeeper-data-files" title="18.6.9. Packages installing scrollkeeper data files">Section 18.6.9, “Packages installing scrollkeeper data files”</a>.</td>
1.85 jmmv 9287: </tr>
9288: <tr>
9289: <td>Installs icons under the
9290: <code class="filename">share/icons/hicolor</code> hierarchy or updates
9291: <code class="filename">share/icons/hicolor/icon-theme.cache</code>.</td>
1.90 ! rillig 9292: <td>See <a href="#hicolor-theme" title="18.6.18. Packages installing hicolor theme icons">Section 18.6.18, “Packages installing hicolor theme icons”</a>.</td>
1.85 jmmv 9293: </tr>
9294: <tr>
9295: <td>Installs files under
9296: <code class="filename">share/mime/packages</code>.</td>
1.90 ! rillig 9297: <td>See <a href="#mime-database" title="18.6.13. Packages installing extensions to the MIME database">Section 18.6.13, “Packages installing extensions to the MIME database”</a>.</td>
1.85 jmmv 9298: </tr>
9299: <tr>
9300: <td>Installs <code class="filename">.desktop</code> files under
9301: <code class="filename">share/applications</code> and these include MIME
9302: information.</td>
1.90 ! rillig 9303: <td>See <a href="#desktop-files" title="18.6.19. Packages installing desktop files">Section 18.6.19, “Packages installing desktop files”</a>.</td>
1.85 jmmv 9304: </tr>
9305: </tbody>
1.89 rillig 9306: </table>
1.85 jmmv 9307: </div>
9308: </div>
9309: <div class="sect1" lang="en">
9310: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9311: <a name="full-update"></a>22.3. Updating GNOME to a newer version</h2></div></div></div>
1.85 jmmv 9312: <p>When seeing GNOME as a whole, there are two kinds of
9313: updates:</p>
9314: <div class="variablelist"><dl>
9315: <dt><span class="term">Major update</span></dt>
9316: <dd>
9317: <p>Given that there is still a very long way for GNOME 3 (if it
9318: ever appears), we consider a major update one that goes from a
9319: <code class="literal">2.X</code> version to a <code class="literal">2.Y</code> one,
9320: where <code class="literal">Y</code> is even and greater than
9321: <code class="literal">X</code>. These are hard to achieve because they
9322: introduce lots of changes in the components' code and almost all
9323: GNOME distfiles are updated to newer versions. Some of them can
9324: even break API and ABI compatibility with the previous major
9325: version series. As a result, the update needs to be done all at
9326: once to minimize breakage.</p>
9327: <p>A major update typically consists of around 80 package
9328: updates and the addition of some new ones.</p>
9329: </dd>
9330: <dt><span class="term">Minor update</span></dt>
9331: <dd>
9332: <p>We consider a minor update one that goes from a
9333: <code class="literal">2.A.X</code> version to a <code class="literal">2.A.Y</code>
9334: one where <code class="literal">Y</code> is greater than
9335: <code class="literal">X</code>. These are easy to achieve because they do
9336: not update all GNOME components, can be done in an incremental way
9337: and do not break API nor ABI compatibility.</p>
9338: <p>A minor update typically consists of around 50 package
9339: updates, although the numbers here may vary a lot.</p>
9340: </dd>
9341: </dl></div>
9342: <p>In order to update the GNOME components in pkgsrc to a new stable
9343: release (either major or minor), the following steps should be
9344: followed:</p>
9345: <div class="orderedlist"><ol type="1">
9346: <li>
9347: <p>Get a list of all the tarballs that form the new release by
9348: using the following commands. These will leave the full list of the
9349: components's distfiles into the <code class="filename">list.txt</code>
9350: file:</p>
1.88 wiz 9351: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>echo ls "*.tar.bz2" | \
1.85 jmmv 9352: ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
9353: awk '{ print $9 }' >list.txt</code></strong>
1.88 wiz 9354: <code class="prompt">%</code> <strong class="userinput"><code>echo ls "*.tar.bz2" | \
1.85 jmmv 9355: ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
9356: awk '{ print $9 }' >>list.txt</code></strong></pre>
9357: </li>
9358: <li><p>Open each meta package's <code class="filename">Makefile</code> and
9359: bump their version to the release you are updating them to. The
9360: three meta packages should be always consistent with versioning.
9361: Obviously remove any <code class="varname">PKGREVISION</code>s that might be
9362: in them.</p></li>
9363: <li>
9364: <p>For each meta package, update all its
9365: <code class="varname">DEPENDS</code> lines to match the latest versions as
9366: shown by the above commands. Do <span class="emphasis"><em>not</em></span> list any
9367: newer version (even if found in the FTP) because the meta packages
9368: are supposed to list the exact versions that form a specific GNOME
9369: release. Exceptions are permitted here if a newer version solves a
9370: serious issue in the overall desktop experience; these typically
9371: come in the form of a revision bump in pkgsrc, not in newer versions
9372: from the developers.</p>
9373: <p>Packages not listed in the <code class="filename">list.txt</code> file
9374: should be updated to the latest version available (if found in
9375: pkgsrc). This is the case, for example, of the dependencies on the
9376: GNU Autotools in the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/gnome-devel/README.html" target="_top"><code class="filename">meta-pkgs/gnome-devel</code></a> meta package.</p>
9377: </li>
9378: <li>
9379: <p>Generate a patch from the modified meta packages and extract the
9380: list of "new" lines. This will provide you an outline on what
9381: packages need to be updated in pkgsrc and in what order:</p>
1.88 wiz 9382: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>cvs diff gnome-devel gnome-base gnome | grep '^+D' >todo.txt</code></strong></pre>
1.85 jmmv 9383: </li>
9384: <li><p>For major desktop updates it is recommended to zap all your
9385: installed packages and start over from scratch at this point.</p></li>
9386: <li><p>Now comes the longest step by far: iterate over the contents
9387: of <code class="filename">todo.txt</code> and update the packages listed in
9388: it in order. For major desktop updates none of these should be
9389: commited until the entire set is completed because there are chances
9390: of breaking not-yet-updated packages.</p></li>
9391: <li><p>Once the packages are up to date and working, commit them to
9392: the tree one by one with appropriate log messages. At the end,
9393: commit the three meta package updates and all the corresponding
9394: changes to the <code class="filename">doc/CHANGES-<YEAR></code> and
9395: <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>
9396: </ol></div>
9397: </div>
9398: <div class="sect1" lang="en">
9399: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9400: <a name="patching"></a>22.4. Patching guidelines</h2></div></div></div>
1.85 jmmv 9401: <p>GNOME is a very big component in pkgsrc which approaches 100
9402: packages. Please, it is very important that you always, always,
9403: <span class="strong"><strong>always</strong></span> feed back any portability
1.90 ! rillig 9404: fixes you do to a GNOME package to the mainstream developers (see <a href="#components.patches.feedback" title="10.3.2. Feedback to the author">Section 10.3.2, “Feedback to the author”</a>). This is the only way to get
1.85 jmmv 9405: their attention on portability issues and to ensure that future versions
9406: can be built out-of-the box on NetBSD. The less custom patches in
9407: pkgsrc, the easier further updates are. Those developers in charge of
9408: issuing major GNOME updates will be grateful if you do that.</p>
9409: <p>The most common places to report bugs are the <a href="http://bugzilla.gnome.org/" target="_top">GNOME's Bugzilla</a> and the <a href="http://bugzilla.freedesktop.org/" target="_top">freedesktop.org's
9410: Bugzilla</a>. Not all components use these to track bugs, but most
9411: of them do. Do not be short on your reports: always provide detailed
9412: explanations of the current failure, how it can be improved to achieve
9413: maximum portability and, if at all possible, provide a patch against CVS
9414: head. The more verbose you are, the higher chances of your patch being
9415: accepted.</p>
9416: <p>Also, please avoid using preprocessor magic to fix portability
9417: issues. While the FreeBSD GNOME people are doing a great job in porting
9418: GNOME to their operating system, the official GNOME sources are now
9419: plagued by conditionals that check for <code class="varname">__FreeBSD__</code>
9420: and similar macros. This hurts portability. Please see our patching
1.90 ! rillig 9421: guidelines (<a href="#components.patches.guidelines" title="10.3.1. Patching guidelines">Section 10.3.1, “Patching guidelines”</a>) for more
1.85 jmmv 9422: details.</p>
9423: </div>
9424: </div>
1.75 rillig 9425: </div>
9426: <div class="part" lang="en">
9427: <div class="titlepage"><div><div><h1 class="title">
9428: <a name="infrastructure"></a>Part III. The pkgsrc infrastructure internals</h1></div></div></div>
9429: <div class="partintro" lang="en">
9430: <div></div>
9431: <p>This part of the guide deals with everything
9432: from the infrastructure that is behind the interfaces described
9433: in the developer's guide. A casual package maintainer should not
9434: need anything from this part.</p>
9435: <div class="toc">
9436: <p><b>Table of Contents</b></p>
9437: <dl>
1.90 ! rillig 9438: <dt><span class="chapter"><a href="#infr.design">23. Design of the pkgsrc infrastructure</a></span></dt>
1.75 rillig 9439: <dd><dl>
1.90 ! rillig 9440: <dt><span class="sect1"><a href="#infr.vardef">23.1. The meaning of variable definitions</a></span></dt>
! 9441: <dt><span class="sect1"><a href="#infr.vardef.problems">23.2. Avoiding problems before they arise</a></span></dt>
! 9442: <dt><span class="sect1"><a href="#infr.var">23.3. Variable evaluation</a></span></dt>
1.75 rillig 9443: <dd><dl>
1.90 ! rillig 9444: <dt><span class="sect2"><a href="#infr.var.load">23.3.1. At load time</a></span></dt>
! 9445: <dt><span class="sect2"><a href="#infr.var.run">23.3.2. At runtime</a></span></dt>
1.75 rillig 9446: </dl></dd>
1.90 ! rillig 9447: <dt><span class="sect1"><a href="#infr.varspec">23.4. How can variables be specified?</a></span></dt>
! 9448: <dt><span class="sect1"><a href="#infr.design.intf">23.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 9449: <dd><dl>
1.90 ! rillig 9450: <dt><span class="sect2"><a href="#infr.design.intf.proc">23.5.1. Procedures with parameters</a></span></dt>
! 9451: <dt><span class="sect2"><a href="#infr.design.intf.action">23.5.2. Actions taken on behalf of parameters</a></span></dt>
1.81 rillig 9452: </dl></dd>
1.90 ! rillig 9453: <dt><span class="sect1"><a href="#infr.order">23.6. The order in which files are loaded</a></span></dt>
1.81 rillig 9454: <dd><dl>
1.90 ! rillig 9455: <dt><span class="sect2"><a href="#infr.order.prefs">23.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
! 9456: <dt><span class="sect2"><a href="#infr.order.pkg">23.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75 rillig 9457: </dl></dd>
9458: </dl></dd>
1.90 ! rillig 9459: <dt><span class="chapter"><a href="#regression">24. Regression tests</a></span></dt>
1.75 rillig 9460: <dd><dl>
1.90 ! rillig 9461: <dt><span class="sect1"><a href="#regression.descr">24.1. The regression tests framework</a></span></dt>
! 9462: <dt><span class="sect1"><a href="#regression.run">24.2. Running the regression tests</a></span></dt>
! 9463: <dt><span class="sect1"><a href="#regression.new">24.3. Adding a new regression test</a></span></dt>
1.75 rillig 9464: <dd><dl>
1.90 ! rillig 9465: <dt><span class="sect2"><a href="#regression.fun.override">24.3.1. Overridable functions</a></span></dt>
! 9466: <dt><span class="sect2"><a href="#regression.fun.helper">24.3.2. Helper functions</a></span></dt>
1.75 rillig 9467: </dl></dd>
9468: </dl></dd>
1.90 ! rillig 9469: <dt><span class="chapter"><a href="#porting">25. Porting pkgsrc</a></span></dt>
1.75 rillig 9470: <dd><dl>
1.90 ! rillig 9471: <dt><span class="sect1"><a href="#porting.opsys">25.1. Porting pkgsrc to a new operating system</a></span></dt>
! 9472: <dt><span class="sect1"><a href="#porting.compiler">25.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 9473: </dl></dd>
9474: </dl>
9475: </div>
9476: </div>
9477: <div class="chapter" lang="en">
9478: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 9479: <a name="infr.design"></a>Chapter 23. Design of the pkgsrc infrastructure</h2></div></div></div>
1.75 rillig 9480: <div class="toc">
9481: <p><b>Table of Contents</b></p>
9482: <dl>
1.90 ! rillig 9483: <dt><span class="sect1"><a href="#infr.vardef">23.1. The meaning of variable definitions</a></span></dt>
! 9484: <dt><span class="sect1"><a href="#infr.vardef.problems">23.2. Avoiding problems before they arise</a></span></dt>
! 9485: <dt><span class="sect1"><a href="#infr.var">23.3. Variable evaluation</a></span></dt>
1.81 rillig 9486: <dd><dl>
1.90 ! rillig 9487: <dt><span class="sect2"><a href="#infr.var.load">23.3.1. At load time</a></span></dt>
! 9488: <dt><span class="sect2"><a href="#infr.var.run">23.3.2. At runtime</a></span></dt>
1.81 rillig 9489: </dl></dd>
1.90 ! rillig 9490: <dt><span class="sect1"><a href="#infr.varspec">23.4. How can variables be specified?</a></span></dt>
! 9491: <dt><span class="sect1"><a href="#infr.design.intf">23.5. Designing interfaces for Makefile fragments</a></span></dt>
1.75 rillig 9492: <dd><dl>
1.90 ! rillig 9493: <dt><span class="sect2"><a href="#infr.design.intf.proc">23.5.1. Procedures with parameters</a></span></dt>
! 9494: <dt><span class="sect2"><a href="#infr.design.intf.action">23.5.2. Actions taken on behalf of parameters</a></span></dt>
1.75 rillig 9495: </dl></dd>
1.90 ! rillig 9496: <dt><span class="sect1"><a href="#infr.order">23.6. The order in which files are loaded</a></span></dt>
1.75 rillig 9497: <dd><dl>
1.90 ! rillig 9498: <dt><span class="sect2"><a href="#infr.order.prefs">23.6.1. The order in <code class="filename">bsd.prefs.mk</code></a></span></dt>
! 9499: <dt><span class="sect2"><a href="#infr.order.pkg">23.6.2. The order in <code class="filename">bsd.pkg.mk</code></a></span></dt>
1.75 rillig 9500: </dl></dd>
9501: </dl>
9502: </div>
9503: <p>The pkgsrc infrastructure consists of many small Makefile
9504: fragments. Each such fragment needs a properly specified
9505: interface. This chapter explains how such an interface looks
9506: like.</p>
9507: <div class="sect1" lang="en">
9508: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9509: <a name="infr.vardef"></a>23.1. The meaning of variable definitions</h2></div></div></div>
1.81 rillig 9510: <p>Whenever a variable is defined in the pkgsrc
9511: infrastructure, the location and the way of definition provide
9512: much information about the intended use of that variable.
9513: Additionally, more documentation may be found in a header
9514: comment or in this pkgsrc guide.</p>
9515: <p>A special file is
9516: <code class="filename">mk/defaults/mk.conf</code>, which lists all
9517: variables that are intended to be user-defined. They are either
9518: defined using the <code class="literal">?=</code> operator or they are
9519: left undefined because defining them to anything would
9520: effectively mean “<span class="quote">yes</span>”. All these variables may be
9521: overridden by the pkgsrc user in the <code class="varname">MAKECONF</code>
9522: file.</p>
9523: <p>Outside this file, the following conventions apply:
9524: Variables that are defined using the <code class="literal">?=</code>
9525: operator may be overridden by a package.</p>
9526: <p>Variables that are defined using the <code class="literal">=</code>
9527: operator may be used read-only at run-time.</p>
9528: <p>Variables whose name starts with an underscore must not be
9529: accessed outside the pkgsrc infrastructure at all. They may
9530: change without further notice.</p>
9531: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
9532: <h3 class="title">Note</h3>
9533: <p>These conventions are currently not applied
9534: consistently to the complete pkgsrc
9535: infrastructure.</p>
9536: </div>
9537: </div>
9538: <div class="sect1" lang="en">
9539: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9540: <a name="infr.vardef.problems"></a>23.2. Avoiding problems before they arise</h2></div></div></div>
1.81 rillig 9541: <p>All variables that contain lists of things should default
9542: to being empty. Two examples that do not follow this rule are
9543: <code class="varname">USE_LANGUAGES</code> and
9544: <code class="varname">DISTFILES</code>. These variables cannot simply be
9545: modified using the <code class="literal">+=</code> operator in package
9546: <code class="filename">Makefile</code>s (or other files included by
9547: them), since there is no guarantee whether the variable is
9548: already set or not, and what its value is. In the case of
9549: <code class="varname">DISTFILES</code>, the packages “<span class="quote">know</span>”
9550: the default value and just define it as in the following
9551: example.</p>
9552: <pre class="programlisting">
9553: DISTFILES= ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
9554: </pre>
9555: <p>Because of the selection of this default value, the same
9556: value appears in many package Makefiles. Similarly for
9557: <code class="varname">USE_LANGUAGES</code>, but in this case the default
9558: value (“<span class="quote"><code class="literal">c</code></span>”) is so short that it
9559: doesn't stand out. Nevertheless it is mentioned in many
9560: files.</p>
9561: </div>
9562: <div class="sect1" lang="en">
9563: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9564: <a name="infr.var"></a>23.3. Variable evaluation</h2></div></div></div>
1.75 rillig 9565: <div class="sect2" lang="en">
9566: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 9567: <a name="infr.var.load"></a>23.3.1. At load time</h3></div></div></div>
1.75 rillig 9568: <p>Variable evaluation takes place either at load time or at
9569: runtime, depending on the context in which they occur. The
9570: contexts where variables are evaluated at load time are:</p>
9571: <div class="itemizedlist"><ul type="disc">
9572: <li><p>The right hand side of the <code class="literal">:=</code>
9573: and <code class="literal">!=</code> operators,</p></li>
9574: <li><p>Make directives like <code class="literal">.if</code> or
9575: <code class="literal">.for</code>,</p></li>
9576: <li><p>Dependency lines.</p></li>
9577: </ul></div>
9578: <p>A special exception are references to the iteration
9579: variables of <code class="literal">.for</code> loops, which are expanded
9580: inline, no matter in which context they appear.</p>
9581: <p>As the values of variables may change during load time,
9582: care must be taken not to evaluate them by accident. Typical
9583: examples for variables that should not be evaluated at load time
9584: are <code class="varname">DEPENDS</code> and
9585: <code class="varname">CONFIGURE_ARGS</code>. To make the effect more
9586: clear, here is an example:</p>
9587: <pre class="programlisting">
9588: CONFIGURE_ARGS= # none
9589: CFLAGS= -O
9590: CONFIGURE_ARGS+= CFLAGS=${CFLAGS:Q}
1.1 grant 9591:
1.75 rillig 9592: CONFIGURE_ARGS:= ${CONFIGURE_ARGS}
1.1 grant 9593:
1.75 rillig 9594: CFLAGS+= -Wall
9595: </pre>
9596: <p>This code shows how the use of the <code class="literal">:=</code>
9597: operator can quickly lead to unexpected results. The first
9598: paragraph is fairly common code. The second paragraph evaluates
9599: the <code class="varname">CONFIGURE_ARGS</code> variable, which results in
9600: <code class="literal">CFLAGS=-O</code>. In the third paragraph, the
9601: <code class="literal">-Wall</code> is appended to the
9602: <code class="varname">CFLAGS</code>, but this addition will not appear in
9603: <code class="varname">CONFIGURE_ARGS</code>. In actual code, the three
9604: paragraphs from above typically occur in completely unrelated
9605: files.</p>
9606: </div>
9607: <div class="sect2" lang="en">
9608: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 9609: <a name="infr.var.run"></a>23.3.2. At runtime</h3></div></div></div>
1.75 rillig 9610: <p>After all the files have been loaded, the values of the
9611: variables cannot be changed anymore. Variables that are used in
9612: the shell commands are expanded at this point.</p>
9613: </div>
9614: </div>
9615: <div class="sect1" lang="en">
9616: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9617: <a name="infr.varspec"></a>23.4. How can variables be specified?</h2></div></div></div>
1.78 rillig 9618: <p>There are many ways in which the definition and use of a
9619: variable can be restricted in order to detect bugs and
9620: violations of the (mostly unwritten) policies. See the
9621: <code class="literal">pkglint</code> developer's documentation for further
9622: details.</p>
9623: </div>
9624: <div class="sect1" lang="en">
9625: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9626: <a name="infr.design.intf"></a>23.5. Designing interfaces for Makefile fragments</h2></div></div></div>
1.76 rillig 9627: <p>Most of the <code class="filename">.mk</code> files fall into one
1.75 rillig 9628: of the following classes. Cases where a file falls into more
9629: than one class should be avoided as it often leads to subtle
9630: bugs.</p>
9631: <div class="sect2" lang="en">
9632: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 9633: <a name="infr.design.intf.proc"></a>23.5.1. Procedures with parameters</h3></div></div></div>
1.75 rillig 9634: <p>In a traditional imperative programming language some of
1.76 rillig 9635: the <code class="filename">.mk</code> files could be described as
1.89 rillig 9636: procedures. They take some input parameters and—after
9637: inclusion—provide a result in output parameters. Since all
1.76 rillig 9638: variables in <code class="filename">Makefile</code>s have global scope
1.75 rillig 9639: care must be taken not to use parameter names that have already
9640: another meaning. For example, <code class="varname">PKGNAME</code> is a
9641: bad choice for a parameter name.</p>
9642: <p>Procedures are completely evaluated at preprocessing time.
9643: That is, when calling a procedure all input parameters must be
9644: completely resolvable. For example,
9645: <code class="varname">CONFIGURE_ARGS</code> should never be an input
9646: parameter since it is very likely that further text will be
9647: added after calling the procedure, which would effectively apply
9648: the procedure to only a part of the variable. Also, references
9649: to other variables wit will be modified after calling the
9650: procedure.</p>
9651: <p>A procedure can declare its output parameters either as
9652: suitable for use in preprocessing directives or as only
9653: available at runtime. The latter alternative is for variables
9654: that contain references to other runtime variables.</p>
9655: <p>Procedures shall be written such that it is possible to
9656: call the procedure more than once. That is, the file must not
9657: contain multiple-inclusion guards.</p>
9658: <p>Examples for procedures are
1.76 rillig 9659: <code class="filename">mk/bsd.options.mk</code> and
9660: <code class="filename">mk/buildlink3/bsd.builtin.mk</code>. To express
1.75 rillig 9661: that the parameters are evaluated at load time, they should be
9662: assigned using the <code class="literal">:=</code> operator, which should
9663: be used only for this purpose.</p>
9664: </div>
9665: <div class="sect2" lang="en">
9666: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 9667: <a name="infr.design.intf.action"></a>23.5.2. Actions taken on behalf of parameters</h3></div></div></div>
1.75 rillig 9668: <p>Action files take some input parameters and may define
9669: runtime variables. They shall not define loadtime variables.
9670: There are action files that are included implicitly by the
9671: pkgsrc infrastructure, while other must be included
9672: explicitly.</p>
9673: <p>An example for action files is
1.76 rillig 9674: <code class="filename">mk/subst.mk</code>.</p>
1.75 rillig 9675: </div>
9676: </div>
1.81 rillig 9677: <div class="sect1" lang="en">
9678: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9679: <a name="infr.order"></a>23.6. The order in which files are loaded</h2></div></div></div>
1.81 rillig 9680: <p>Package <code class="filename">Makefile</code>s usually consist of
9681: a set of variable definitions, and include the file
9682: <code class="filename">../../mk/bsd.pkg.mk</code> in the very last line.
9683: Before that, they may also include various other
9684: <code class="filename">*.mk</code> files if they need to query the
9685: availability of certain features like the type of compiler or
9686: the X11 implementation. Due to the heavy use of preprocessor
9687: directives like <code class="literal">.if</code> and
9688: <code class="literal">.for</code>, the order in which the files are loaded
9689: matters.</p>
9690: <p>This section describes at which point the various files
9691: are loaded and gives reasons for that order.</p>
9692: <div class="sect2" lang="en">
9693: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 9694: <a name="infr.order.prefs"></a>23.6.1. The order in <code class="filename">bsd.prefs.mk</code></h3></div></div></div>
1.81 rillig 9695: <p>The very first action in <code class="filename">bsd.pkg.mk</code>
9696: is to define some essential variables like
9697: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code> and
9698: <code class="varname">MACHINE_ARCH</code>.</p>
9699: <p>Then, the user settings are loaded from the file specified
9700: in <code class="varname">MAKECONF</code>. If the bmake command from pkgsrc
9701: is used, <code class="varname">MAKECONF</code> defaults to
9702: <code class="filename"><em class="replaceable"><code>${prefix}</code></em>/etc/mk.conf</code>.
9703: With the native <a href="http://netbsd.gw.com/cgi-bin/man-cgi?make+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> command on NetBSD, it defaults to
9704: <code class="filename">/etc/mk.conf</code>. After that, those variables
9705: that have not been overridden by the user are loaded from
9706: <code class="filename">mk/defaults/mk.conf</code>.</p>
9707: <p>After the user settings, the system settings and platform
9708: settings are loaded, which may override the user
9709: settings.</p>
9710: <p>Then, the tool definitions are loaded. The tool wrappers
9711: are not yet in effect. This only happens when building a
9712: package, so the proper variables must be used instead of the
9713: direct tool names.</p>
9714: <p>As the last steps, some essential variables from the
9715: wrapper and the package system flavor are loaded, as well as the
9716: variables that have been cached in earlier phases of a package
9717: build.</p>
9718: </div>
9719: <div class="sect2" lang="en">
9720: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 9721: <a name="infr.order.pkg"></a>23.6.2. The order in <code class="filename">bsd.pkg.mk</code></h3></div></div></div>
1.81 rillig 9722: <p>First, <code class="filename">bsd.prefs.mk</code> is loaded.</p>
9723: <p>Then, the various <code class="filename">*-vars.mk</code> files are
9724: loaded, which fill default values for those variables that have
9725: not been defined by the the package. These variables may later
9726: be used even in unrelated files.</p>
9727: <p>Then, the file <code class="filename">bsd.pkg.error.mk</code>
9728: provides the target <code class="literal">error-check</code> that is added
9729: as a special dependency to all other targets that use
9730: <code class="varname">DELAYED_ERROR_MSG</code> or
9731: <code class="varname">DELAYED_WARNING_MSG</code>.</p>
9732: <p>Then, the package-specific hacks from
9733: <code class="filename">hacks.mk</code> are included.</p>
9734: <p>Then, various other files follow. Most of them don't have
9735: any dependencies on what they need to have included before or
9736: after them, though some do.</p>
9737: <p>The code to check <code class="varname">PKG_FAIL_REASON</code> and
9738: <code class="varname">PKG_SKIP_REASON</code> is then executed, which
9739: restricts the use of these variables to all the files that have
9740: been included before. Appearances in later files will be
9741: silently ignored.</p>
9742: <p>Then, the files for the main targets are included, in the
9743: order of later execution, though the actual order should not
9744: matter.</p>
9745: <p>At last, some more files are included that don't set any
9746: interesting variables but rather just define make targets to be
9747: executed.</p>
9748: </div>
9749: </div>
1.75 rillig 9750: </div>
9751: <div class="chapter" lang="en">
9752: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 9753: <a name="regression"></a>Chapter 24. Regression tests</h2></div></div></div>
1.75 rillig 9754: <div class="toc">
9755: <p><b>Table of Contents</b></p>
9756: <dl>
1.90 ! rillig 9757: <dt><span class="sect1"><a href="#regression.descr">24.1. The regression tests framework</a></span></dt>
! 9758: <dt><span class="sect1"><a href="#regression.run">24.2. Running the regression tests</a></span></dt>
! 9759: <dt><span class="sect1"><a href="#regression.new">24.3. Adding a new regression test</a></span></dt>
1.75 rillig 9760: <dd><dl>
1.90 ! rillig 9761: <dt><span class="sect2"><a href="#regression.fun.override">24.3.1. Overridable functions</a></span></dt>
! 9762: <dt><span class="sect2"><a href="#regression.fun.helper">24.3.2. Helper functions</a></span></dt>
1.75 rillig 9763: </dl></dd>
9764: </dl>
9765: </div>
9766: <p>The pkgsrc infrastructure consists of a large codebase,
9767: and there are many corners where every little bit of a file is
9768: well thought out, making pkgsrc likely to fail as soon as
9769: anything is changed near those parts. To prevent most changes
9770: from breaking anything, a suite of regression tests should go
9771: along with every important part of the pkgsrc infrastructure.
9772: This chapter describes how regression tests work in pkgsrc and
9773: how you can add new tests.</p>
9774: <div class="sect1" lang="en">
9775: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9776: <a name="regression.descr"></a>24.1. The regression tests framework</h2></div></div></div>
1.75 rillig 9777: <p></p>
9778: </div>
9779: <div class="sect1" lang="en">
9780: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9781: <a name="regression.run"></a>24.2. Running the regression tests</h2></div></div></div>
1.76 rillig 9782: <p>You first need to install the <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkg_regress/README.html" target="_top"><code class="filename">pkgtools/pkg_regress</code></a> package, which
1.75 rillig 9783: provides the <span><strong class="command">pkg_regress</strong></span> command. Then you
9784: can simply run that command, which will run all tests in the
1.76 rillig 9785: <code class="filename">regress</code> category.</p>
1.75 rillig 9786: </div>
9787: <div class="sect1" lang="en">
9788: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9789: <a name="regression.new"></a>24.3. Adding a new regression test</h2></div></div></div>
1.76 rillig 9790: <p>Every directory in the <code class="filename">regress</code>
9791: category that contains a file called <code class="filename">spec</code>
1.75 rillig 9792: is considered a regression test. This file is a shell program
9793: that is included by the <span><strong class="command">pkg_regress</strong></span> command.
9794: The following functions can be overridden to suit your
9795: needs.</p>
9796: <div class="sect2" lang="en">
9797: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 9798: <a name="regression.fun.override"></a>24.3.1. Overridable functions</h3></div></div></div>
1.75 rillig 9799: <p>These functions do not take any parameters. They are all
9800: called in “<span class="quote">set -e</span>” mode, so you should be careful
9801: to check the exitcodes of any commands you run in the
9802: test.</p>
9803: <div class="variablelist"><dl>
9804: <dt><span class="term"><code class="varname">do_setup()</code></span></dt>
9805: <dd><p>This function prepares the environment for the
9806: test. By default it does nothing.</p></dd>
9807: <dt><span class="term"><code class="varname">do_test()</code></span></dt>
9808: <dd><p>This function runs the actual test. By default,
9809: it calls <code class="varname">TEST_MAKE</code> with the arguments
9810: <code class="varname">MAKEARGS_TEST</code> and writes its output including
9811: error messages into the file
9812: <code class="varname">TEST_OUTFILE</code>.</p></dd>
9813: <dt><span class="term"><code class="varname">check_result()</code></span></dt>
9814: <dd><p>This function is run after the test and is
9815: typically used to compare the actual output from the one that is
9816: expected. It can make use of the various helper functions from
9817: the next section.</p></dd>
9818: <dt><span class="term"><code class="varname">do_cleanup()</code></span></dt>
9819: <dd><p>This function cleans everything up after the
9820: test has been run. By default it does nothing.</p></dd>
9821: </dl></div>
9822: </div>
9823: <div class="sect2" lang="en">
9824: <div class="titlepage"><div><div><h3 class="title">
1.90 ! rillig 9825: <a name="regression.fun.helper"></a>24.3.2. Helper functions</h3></div></div></div>
1.75 rillig 9826: <div class="variablelist"><dl>
9827: <dt><span class="term"><code class="varname">exit_status(expected)</code></span></dt>
9828: <dd><p>This function compares the exitcode of the
9829: <span><strong class="command">do_test()</strong></span> function with its first parameter.
9830: If they differ, the test will fail.</p></dd>
9831: <dt><span class="term"><code class="varname">output_require(regex...)</code></span></dt>
9832: <dd><p>This function checks for each of its parameters
9833: if the output from <span><strong class="command">do_test()</strong></span> matches the
9834: extended regular expression. If it does not, the test will
9835: fail.</p></dd>
9836: <dt><span class="term"><code class="varname">output_prohibit(regex...)</code></span></dt>
9837: <dd><p>This function checks for each of its parameters
9838: if the output from <span><strong class="command">do_test()</strong></span> does
9839: <span class="emphasis"><em>not</em></span> match the extended regular expression.
9840: If any of the regular expressions matches, the test will
9841: fail.</p></dd>
9842: </dl></div>
9843: </div>
9844: </div>
9845: </div>
9846: <div class="chapter" lang="en">
9847: <div class="titlepage"><div><div><h2 class="title">
1.90 ! rillig 9848: <a name="porting"></a>Chapter 25. Porting pkgsrc</h2></div></div></div>
1.75 rillig 9849: <div class="toc">
9850: <p><b>Table of Contents</b></p>
9851: <dl>
1.90 ! rillig 9852: <dt><span class="sect1"><a href="#porting.opsys">25.1. Porting pkgsrc to a new operating system</a></span></dt>
! 9853: <dt><span class="sect1"><a href="#porting.compiler">25.2. Adding support for a new compiler</a></span></dt>
1.75 rillig 9854: </dl>
9855: </div>
9856: <p>The pkgsrc system has already been ported to many
9857: operating systems, hardware architectures and compilers. This
9858: chapter explains the necessary steps to make pkgsrc even more
9859: portable.</p>
9860: <div class="sect1" lang="en">
9861: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9862: <a name="porting.opsys"></a>25.1. Porting pkgsrc to a new operating system</h2></div></div></div>
1.75 rillig 9863: <p>To port pkgsrc to a new operating system (called
9864: <code class="literal">MyOS</code> in this example), you need to touch the
9865: following files:</p>
9866: <div class="variablelist"><dl>
1.76 rillig 9867: <dt><span class="term"><code class="filename">bootstrap/mods/mk/<em class="replaceable"><code>MyOS</code></em>.sys.mk</code></span></dt>
1.75 rillig 9868: <dd><p>This file contains some basic definitions, for
9869: example the name of the C
9870: compiler.</p></dd>
1.76 rillig 9871: <dt><span class="term"><code class="filename">mk/bsd.prefs.mk</code></span></dt>
1.75 rillig 9872: <dd><p>Insert code that defines the variables
9873: <code class="varname">OPSYS</code>, <code class="varname">OS_VERSION</code>,
9874: <code class="varname">LOWER_OS_VERSION</code>,
9875: <code class="varname">LOWER_VENDOR</code>,
9876: <code class="varname">MACHINE_ARCH</code>, <code class="varname">OBJECT_FMT</code>,
9877: <code class="varname">APPEND_ELF</code>, and the other variables that
9878: appear in this file.</p></dd>
1.76 rillig 9879: <dt><span class="term"><code class="filename">mk/platform/MyOS.mk</code></span></dt>
1.75 rillig 9880: <dd><p>This file contains the platform-specific
9881: definitions that are used by pkgsrc. Start by copying one of the
9882: other files and edit it to your
9883: needs.</p></dd>
1.76 rillig 9884: <dt><span class="term"><code class="filename">mk/platform/MyOS.pkg.dist</code></span></dt>
1.75 rillig 9885: <dd><p>This file contains a list of directories,
9886: together with their permission bits and ownership. These
9887: directories will be created automatically with every package
9888: that does not explicitly set <code class="varname">NO_MTREE</code>. There
9889: have been some discussions about whether this file is needed at
9890: all, but with no result.</p></dd>
1.76 rillig 9891: <dt><span class="term"><code class="filename">mk/platform/MyOS.x11.dist</code></span></dt>
1.75 rillig 9892: <dd><p>Just copy one of the pre-existing x11.dist files
9893: to your
1.76 rillig 9894: <code class="filename"><em class="replaceable"><code>MyOS</code></em>.x11.dist</code>.</p></dd>
9895: <dt><span class="term"><code class="filename">mk/tools/bootstrap.mk</code></span></dt>
1.75 rillig 9896: <dd><p>On some operating systems, the tools that are
9897: provided with the base system are not good enough for pkgsrc.
9898: For example, there are many versions of <a href="http://netbsd.gw.com/cgi-bin/man-cgi?sed+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">sed</span>(1)</span></a> that have a
9899: narrow limit on the line length they can process. Therefore
9900: pkgsrc brings its own tools, which can be enabled
9901: here.</p></dd>
1.76 rillig 9902: <dt><span class="term"><code class="filename">mk/tools/<em class="replaceable"><code>MyOS</code></em>.mk</code></span></dt>
1.75 rillig 9903: <dd><p>This file defines the paths to all the tools
9904: that are needed by one or the other package in pkgsrc, as well
9905: as by pkgsrc itself. Find out where these tools are on your
9906: platform and add them.</p></dd>
9907: </dl></div>
9908: <p>Now, you should be able to build some basic packages, like
1.76 rillig 9909: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/lang/perl5/README.html" target="_top"><code class="filename">lang/perl5</code></a>, <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/shells/bash/README.html" target="_top"><code class="filename">shells/bash</code></a>.</p>
1.75 rillig 9910: </div>
9911: <div class="sect1" lang="en">
9912: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.90 ! rillig 9913: <a name="porting.compiler"></a>25.2. Adding support for a new compiler</h2></div></div></div>
1.75 rillig 9914: <p>TODO</p>
9915: </div>
9916: </div>
9917: </div>
9918: <div class="appendix" lang="en">
9919: <div class="titlepage"><div><div><h2 class="title">
9920: <a name="examples"></a>Appendix A. A simple example package: bison</h2></div></div></div>
9921: <div class="toc">
9922: <p><b>Table of Contents</b></p>
9923: <dl>
9924: <dt><span class="sect1"><a href="#example-files">A.1. files</a></span></dt>
9925: <dd><dl>
9926: <dt><span class="sect2"><a href="#example-Makefile">A.1.1. Makefile</a></span></dt>
9927: <dt><span class="sect2"><a href="#example-descr">A.1.2. DESCR</a></span></dt>
9928: <dt><span class="sect2"><a href="#example-plist">A.1.3. PLIST</a></span></dt>
9929: <dt><span class="sect2"><a href="#checking-package-with-pkglint">A.1.4. Checking a package with <span><strong class="command">pkglint</strong></span></a></span></dt>
9930: </dl></dd>
9931: <dt><span class="sect1"><a href="#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
9932: </dl>
9933: </div>
9934: <p>We checked to find a piece of software that wasn't in the packages
9935: collection, and picked GNU bison. Quite why someone would want to have
9936: <span><strong class="command">bison</strong></span> when Berkeley <span><strong class="command">yacc</strong></span> is already
9937: present in the tree is beyond us, but it's useful for the purposes of
9938: this exercise.</p>
9939: <div class="sect1" lang="en">
9940: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
9941: <a name="example-files"></a>A.1. files</h2></div></div></div>
9942: <div class="sect2" lang="en">
9943: <div class="titlepage"><div><div><h3 class="title">
9944: <a name="example-Makefile"></a>A.1.1. Makefile</h3></div></div></div>
9945: <pre class="programlisting">
1.51 rillig 9946: # $NetBSD$
9947: #
1.1 grant 9948:
1.51 rillig 9949: DISTNAME= bison-1.25
9950: CATEGORIES= devel
9951: MASTER_SITES= ${MASTER_SITE_GNU}
1.1 grant 9952:
1.51 rillig 9953: MAINTAINER= thorpej@NetBSD.org
9954: HOMEPAGE= http://www.gnu.org/software/bison/bison.html
9955: COMMENT= GNU yacc clone
1.1 grant 9956:
1.51 rillig 9957: GNU_CONFIGURE= yes
9958: INFO_FILES= bison.info
1.1 grant 9959:
1.51 rillig 9960: .include "../../mk/bsd.pkg.mk"
1.1 grant 9961: </pre>
1.75 rillig 9962: </div>
9963: <div class="sect2" lang="en">
9964: <div class="titlepage"><div><div><h3 class="title">
9965: <a name="example-descr"></a>A.1.2. DESCR</h3></div></div></div>
9966: <pre class="programlisting">
1.51 rillig 9967: GNU version of yacc. Can make re-entrant parsers, and numerous other
1.75 rillig 9968: improvements. Why you would want this when Berkeley <a href="http://netbsd.gw.com/cgi-bin/man-cgi?yacc+1+NetBSD-current"><span class="citerefentry"><span class="refentrytitle">yacc</span>(1)</span></a> is part
1.51 rillig 9969: of the NetBSD source tree is beyond me.
1.1 grant 9970: </pre>
1.75 rillig 9971: </div>
9972: <div class="sect2" lang="en">
9973: <div class="titlepage"><div><div><h3 class="title">
9974: <a name="example-plist"></a>A.1.3. PLIST</h3></div></div></div>
9975: <pre class="programlisting">
1.51 rillig 9976: @comment $NetBSD$
9977: bin/bison
9978: man/man1/bison.1.gz
9979: share/bison.simple
9980: share/bison.hairy
1.1 grant 9981: </pre>
1.75 rillig 9982: </div>
9983: <div class="sect2" lang="en">
9984: <div class="titlepage"><div><div><h3 class="title">
9985: <a name="checking-package-with-pkglint"></a>A.1.4. Checking a package with <span><strong class="command">pkglint</strong></span></h3></div></div></div>
9986: <p>The NetBSD package system comes with
1.76 rillig 9987: <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>
1.75 rillig 9988: which helps to check the contents of these
9989: files. After installation it is quite easy to use, just change to the
9990: directory of the package you wish to examine and execute
9991: <span><strong class="command">pkglint</strong></span>:</p>
9992: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
9993: looks fine.</pre>
9994: <p>Depending on the supplied command line arguments (see pkglint(1)),
9995: more checks will be performed. Use e.g. <span><strong class="command">pkglint -Call
9996: -Wall</strong></span> for a very thorough check.</p>
9997: </div>
9998: </div>
9999: <div class="sect1" lang="en">
10000: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10001: <a name="steps-for-b-i-p"></a>A.2. Steps for building, installing, packaging</h2></div></div></div>
10002: <p>Create the directory where the package lives,
10003: plus any auxiliary directories:</p>
10004: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
10005: <code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
10006: <code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
10007: <code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
1.76 rillig 10008: <p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
1.90 ! rillig 10009: <code class="filename">PLIST</code> (see <a href="#components" title="Chapter 10. Package components - files, directories and contents">Chapter 10, <i>Package components - files, directories and contents</i></a>)
1.75 rillig 10010: then continue with fetching the distfile:</p>
10011: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
1.1 grant 10012: >> bison-1.25.tar.gz doesn't seem to exist on this system.
10013: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
10014: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
10015: ftp: Error retrieving file: 500 Internal error
10016:
10017: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
10018: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
10019: ftp: Error retrieving file: 500 Internal error
10020:
10021: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
10022: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
1.75 rillig 10023: Successfully retrieved file.</pre>
10024: <p>Generate the checksum of the distfile into
1.76 rillig 10025: <code class="filename">distinfo</code>:</p>
1.88 wiz 10026: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makedistinfo</code></strong></pre>
1.75 rillig 10027: <p>Now compile:</p>
10028: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 10029: >> Checksum OK for bison-1.25.tar.gz.
10030: ===> Extracting for bison-1.25
10031: ===> Patching for bison-1.25
10032: ===> Ignoring empty patch directory
10033: ===> Configuring for bison-1.25
10034: creating cache ./config.cache
10035: checking for gcc... cc
10036: checking whether we are using GNU C... yes
10037: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
10038: checking how to run the C preprocessor... cc -E
10039: checking for minix/config.h... no
10040: checking for POSIXized ISC... no
10041: checking whether cross-compiling... no
10042: checking for ANSI C header files... yes
10043: checking for string.h... yes
10044: checking for stdlib.h... yes
10045: checking for memory.h... yes
10046: checking for working const... yes
10047: checking for working alloca.h... no
10048: checking for alloca... yes
10049: checking for strerror... yes
10050: updating cache ./config.cache
10051: creating ./config.status
10052: creating Makefile
10053: ===> Building for bison-1.25
10054: 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
10055: 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
10056: 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
10057: 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
10058: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include -g derives.c
1.68 rillig 10059: cc -c -DXPFILE=\"/usr/pkg/share/bison.simple\" -DXPFILE1=\"/usr/pkg/share/bison.hairy\" -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -g ./files.c
1.1 grant 10060: 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
10061: 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
10062: 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
10063: 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
10064: 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
10065: 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
10066: 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
10067: 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
10068: 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
10069: 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
10070: 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
10071: 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
10072: 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
10073: 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
10074: 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
10075: 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
10076: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
10077: rm -f bison.s1
1.75 rillig 10078: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1</pre>
10079: <p>Everything seems OK, so install the files:</p>
10080: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 10081: >> Checksum OK for bison-1.25.tar.gz.
10082: ===> Installing for bison-1.25
10083: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share /usr/pkg/info /usr/pkg/man/man1
10084: rm -f /usr/pkg/bin/bison
10085: cd /usr/pkg/share; rm -f bison.simple bison.hairy
10086: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
10087: install -c -o bin -g bin -m 555 bison /usr/pkg/bin/bison
10088: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
10089: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
10090: cd .; for f in bison.info*; do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
10091: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
1.75 rillig 10092: ===> Registering installation for bison-1.25</pre>
10093: <p>You can now use bison, and also - if you decide so - remove it with
10094: <span><strong class="command">pkg_delete bison</strong></span>. Should you decide that you want a
10095: binary package, do this now:</p>
10096: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 10097: >> Checksum OK for bison-1.25.tar.gz.
10098: ===> Building package for bison-1.25
10099: Creating package bison-1.25.tgz
10100: Registering depends:.
1.75 rillig 10101: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
10102: <p>Now that you don't need the source and object files
10103: any more, clean up:</p>
10104: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
10105: ===> Cleaning for bison-1.25</pre>
10106: </div>
10107: </div>
10108: <div class="appendix" lang="en">
10109: <div class="titlepage"><div><div><h2 class="title">
10110: <a name="logs"></a>Appendix B. Build logs</h2></div></div></div>
10111: <div class="toc">
10112: <p><b>Table of Contents</b></p>
10113: <dl>
10114: <dt><span class="sect1"><a href="#logs.building">B.1. Building figlet</a></span></dt>
10115: <dt><span class="sect1"><a href="#logs.package">B.2. Packaging figlet</a></span></dt>
10116: </dl>
10117: </div>
10118: <div class="sect1" lang="en">
10119: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10120: <a name="logs.building"></a>B.1. Building figlet</h2></div></div></div>
10121: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
1.1 grant 10122: ===> Checking for vulnerabilities in figlet-2.2.1nb2
10123: => figlet221.tar.gz doesn't seem to exist on this system.
10124: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
10125: => [172219 bytes]
10126: Connected to ftp.plig.net.
10127: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
10128: 331 Guest login ok, send your complete e-mail address as password.
10129: 230-You are user #5 of 500 simultaneous users allowed.
10130: 230-
1.68 rillig 10131: 230- ___ _ _ _
10132: 230- | _| |_ ___ ___| |_|___ ___ ___ ___
1.1 grant 10133: 230- | _| _| . |_| . | | | . |_| . | _| . |
10134: 230- |_| |_| | _|_| _|_|_|_ |_|___|_| |_ |
10135: 230- |_| |_| |___| |___|
10136: 230-
10137: 230-** Welcome to ftp.plig.org **
10138: 230-
10139: 230-Please note that all transfers from this FTP site are logged. If you
10140: 230-do not like this, please disconnect now.
10141: 230-
10142: 230-This arhive is available via
10143: 230-
10144: 230-HTTP: http://ftp.plig.org/
10145: 230-FTP: ftp://ftp.plig.org/ (max 500 connections)
10146: 230-RSYNC: rsync://ftp.plig.org/ (max 30 connections)
10147: 230-
10148: 230-Please email comments, bug reports and requests for packages to be
1.68 rillig 10149: 230-mirrored to ftp-admin@plig.org.
1.1 grant 10150: 230-
10151: 230-
10152: 230 Logged in anonymously.
10153: Remote system type is UNIX.
10154: Using binary mode to transfer files.
10155: 200 Type okay.
10156: 250 "/pub" is new cwd.
10157: 250-"/pub/figlet" is new cwd.
10158: 250-
10159: 250-Welcome to the figlet archive at ftp.figlet.org
1.68 rillig 10160: 250-
1.75 rillig 10161: 250- ftp://ftp.figlet.org/pub/figlet/
1.1 grant 10162: 250-
10163: 250-The official FIGlet web page is:
1.75 rillig 10164: 250- http://www.figlet.org/
1.1 grant 10165: 250-
10166: 250-If you have questions, please mailto:info@figlet.org. If you want to
10167: 250-contribute a font or something else, you can email us.
1.68 rillig 10168: 250
1.1 grant 10169: 250 "/pub/figlet/program" is new cwd.
10170: 250 "/pub/figlet/program/unix" is new cwd.
10171: local: figlet221.tar.gz remote: figlet221.tar.gz
10172: 502 Unimplemented command.
10173: 227 Entering Passive Mode (195,40,6,41,246,104)
10174: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
10175: 38% |************** | 65800 64.16 KB/s 00:01 ETA
10176: 226 Transfer completed.
10177: 172219 bytes received in 00:02 (75.99 KB/s)
10178: 221 Goodbye.
10179: => Checksum OK for figlet221.tar.gz.
10180: ===> Extracting for figlet-2.2.1nb2
10181: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
10182: ===> Patching for figlet-2.2.1nb2
10183: ===> Applying pkgsrc patches for figlet-2.2.1nb2
10184: ===> Overriding tools for figlet-2.2.1nb2
10185: ===> Creating toolchain wrappers for figlet-2.2.1nb2
10186: ===> Configuring for figlet-2.2.1nb2
10187: ===> Building for figlet-2.2.1nb2
10188: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\" -DDEFAULTFONTFILE=\"standard.flf\" figlet.c zipio.c crc.c inflate.c -o figlet
10189: chmod a+x figlet
10190: gcc -O2 -o chkfont chkfont.c
10191: => Unwrapping files-to-be-installed.
1.14 xtraeme 10192: <code class="prompt">#</code>
1.75 rillig 10193: <code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
1.1 grant 10194: ===> Checking for vulnerabilities in figlet-2.2.1nb2
10195: ===> Installing for figlet-2.2.1nb2
10196: install -d -o root -g wheel -m 755 /usr/pkg/bin
10197: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
10198: mkdir -p /usr/pkg/share/figlet
10199: cp figlet /usr/pkg/bin
10200: cp chkfont /usr/pkg/bin
10201: chmod 555 figlist showfigfonts
10202: cp figlist /usr/pkg/bin
10203: cp showfigfonts /usr/pkg/bin
10204: cp fonts/*.flf /usr/pkg/share/figlet
10205: cp fonts/*.flc /usr/pkg/share/figlet
10206: cp figlet.6 /usr/pkg/man/man6
10207: ===> Registering installation for figlet-2.2.1nb2
1.75 rillig 10208: <code class="prompt">#</code></pre>
10209: </div>
10210: <div class="sect1" lang="en">
10211: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10212: <a name="logs.package"></a>B.2. Packaging figlet</h2></div></div></div>
10213: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
1.1 grant 10214: ===> Checking for vulnerabilities in figlet-2.2.1nb2
10215: ===> Packaging figlet-2.2.1nb2
10216: ===> Building binary package for figlet-2.2.1nb2
10217: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
10218: Using SrcDir value of /usr/pkg
1.68 rillig 10219: Registering depends:.
1.75 rillig 10220: <code class="prompt">#</code></pre>
10221: </div>
10222: </div>
10223: <div class="appendix" lang="en">
10224: <div class="titlepage"><div><div><h2 class="title">
1.76 rillig 10225: <a name="ftp-layout"></a>Appendix C. Directory layout of the pkgsrc FTP server</h2></div></div></div>
10226: <div class="toc">
10227: <p><b>Table of Contents</b></p>
10228: <dl>
10229: <dt><span class="sect1"><a href="#ftp-bootstrap">C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</a></span></dt>
10230: <dt><span class="sect1"><a href="#ftp-distfiles">C.2. <code class="filename">distfiles</code>: The distributed source files</a></span></dt>
10231: <dt><span class="sect1"><a href="#ftp-iso">C.3. <code class="filename">iso</code>: Currently empty</a></span></dt>
10232: <dt><span class="sect1"><a href="#ftp-misc">C.4. <code class="filename">misc</code>: Miscellaneous things</a></span></dt>
10233: <dt><span class="sect1"><a href="#ftp-packages">C.5. <code class="filename">packages*</code>: Binary packages</a></span></dt>
10234: <dt><span class="sect1"><a href="#ftp-source">C.6. <code class="filename">current</code>,
10235: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
10236: source packages</a></span></dt>
10237: </dl>
10238: </div>
10239: <p>As in other big projects, the directory layout of pkgsrc
10240: is quite complex for newbies. This chapter explains where you
10241: find things on the FTP server. The base directory on
1.89 rillig 10242: <code class="filename">ftp.NetBSD.org</code> is <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/" target="_top"><code class="filename">/pub/pkgsrc/</code></a>.
10243: On other servers it may be different, but inside this directory,
10244: everything should look the same, no matter on which server you
10245: are. This directory contains some subdirectories, which are
10246: explained below.</p>
1.76 rillig 10247: <div class="sect1" lang="en">
10248: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10249: <a name="ftp-bootstrap"></a>C.1. <code class="filename">bootstrap-pkgsrc</code>: Bootstrap kits</h2></div></div></div>
10250: <p>For those who only want to manage binary packages on
10251: systems other than NetBSD, we provide the package management
10252: tools in a separate, small tar file.</p>
10253: </div>
10254: <div class="sect1" lang="en">
10255: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10256: <a name="ftp-distfiles"></a>C.2. <code class="filename">distfiles</code>: The distributed source files</h2></div></div></div>
10257: <p>The directory <code class="filename">distfiles</code> contains lots
10258: of archive files from all pkgsrc packages, which are mirrored
10259: here. The subdirectories are called after their package names
10260: and are used when the distributed files have names that don't
10261: explicitly contain a version number or are otherwise too generic
10262: (for example <code class="filename">release.tar.gz</code>).</p>
10263: </div>
10264: <div class="sect1" lang="en">
10265: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10266: <a name="ftp-iso"></a>C.3. <code class="filename">iso</code>: Currently empty</h2></div></div></div>
10267: <p>This directory is currently not in use.</p>
10268: </div>
10269: <div class="sect1" lang="en">
10270: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10271: <a name="ftp-misc"></a>C.4. <code class="filename">misc</code>: Miscellaneous things</h2></div></div></div>
10272: <p>This directory contains things that individual pkgsrc
10273: developers find worth publishing.</p>
10274: </div>
10275: <div class="sect1" lang="en">
10276: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10277: <a name="ftp-packages"></a>C.5. <code class="filename">packages*</code>: Binary packages</h2></div></div></div>
10278: <p>These directories contain binary packages. Those
10279: directories that have a branch name
10280: (200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>)
10281: contain packages from that particular branch. The directory
10282: <code class="filename">packages</code> contains binary packages from
10283: pkgsrc-current. (However, this does not necessarily mean that
10284: the packages are still current anymore.)</p>
10285: <p>Below the <code class="filename">packages*</code> directories are
10286: directories that distinguish the packages by operating system
10287: and version, the next directory level specifies the hardware
10288: architecture.</p>
10289: <p>In each of the platform-specific directories, there is a
10290: whole binary packages collection. It has a directory called
10291: <code class="filename">All</code> which contains all binary packages.
10292: Besides that, there are various category directories that
10293: contain symbolic links to the real binary packages.</p>
10294: </div>
10295: <div class="sect1" lang="en">
10296: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10297: <a name="ftp-source"></a>C.6. <code class="filename">current</code>,
10298: <code class="filename">200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em></code>:
10299: source packages</h2></div></div></div>
10300: <p>These directories contain the “<span class="quote">real</span>” pkgsrc,
10301: that is the files that define how to create binary packages from
10302: source archives.</p>
10303: <p>The directory <code class="filename">pkgsrc</code> contains a
1.89 rillig 10304: snapshot of the CVS repository, which is updated regularly. The
10305: file <code class="filename">pkgsrc.tar.gz</code> contains the same as the
10306: directory, ready to be downloaded as a whole.</p>
1.76 rillig 10307: <p>In the directories for the quarterly branches, there is an
10308: additional file called
10309: <code class="filename">pkgsrc-200<em class="replaceable"><code>x</code></em>Q<em class="replaceable"><code>y</code></em>.tar.gz</code>,
10310: which contains the state of pkgsrc when it was branched.</p>
10311: </div>
1.75 rillig 10312: </div>
10313: <div class="appendix" lang="en">
10314: <div class="titlepage"><div><div><h2 class="title">
10315: <a name="editing"></a>Appendix D. Editing guidelines for the pkgsrc guide</h2></div></div></div>
10316: <div class="toc">
10317: <p><b>Table of Contents</b></p>
10318: <dl>
1.79 rillig 10319: <dt><span class="sect1"><a href="#targets">D.1. Make targets</a></span></dt>
1.75 rillig 10320: <dt><span class="sect1"><a href="#procedure">D.2. Procedure</a></span></dt>
10321: </dl>
10322: </div>
1.79 rillig 10323: <p>This section contains information on editing the pkgsrc
10324: guide itself.</p>
1.75 rillig 10325: <div class="sect1" lang="en">
10326: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.79 rillig 10327: <a name="targets"></a>D.1. Make targets</h2></div></div></div>
10328: <p>The pkgsrc guide's source code is stored in
10329: <code class="filename">pkgsrc/doc/guide/files</code>, and several files
10330: are created from it:</p>
10331: <div class="itemizedlist"><ul type="disc">
10332: <li><p><code class="filename">pkgsrc/doc/pkgsrc.txt</code></p></li>
10333: <li><p><code class="filename">pkgsrc/doc/pkgsrc.html</code></p></li>
10334: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/</a></p></li>
10335: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.pdf</a>:
10336: The PDF version of the pkgsrc guide.</p></li>
10337: <li><p><a href="http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps" target="_top">http://www.NetBSD.org/Documentation/pkgsrc/pkgsrc.ps</a>:
10338: PostScript version of the pkgsrc guide.</p></li>
1.75 rillig 10339: </ul></div>
10340: </div>
10341: <div class="sect1" lang="en">
10342: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
10343: <a name="procedure"></a>D.2. Procedure</h2></div></div></div>
1.79 rillig 10344: <p>The procedure to edit the pkgsrc guide is:</p>
10345: <div class="procedure"><ol type="1">
10346: <li><p>Make sure you have the packages needed to
1.83 wiz 10347: regenerate the pkgsrc guide (and other XML-based NetBSD
1.79 rillig 10348: documentation) installed. These are <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/netbsd-doc/README.html" target="_top"><code class="filename">meta-pkgs/netbsd-doc</code></a> for creating the
10349: ASCII and HTML versions, and <a href="ftp://ftp.NetBSD.org/pub/NetBSD/packages/pkgsrc/meta-pkgs/netbsd-doc-print/README.html" target="_top"><code class="filename">meta-pkgs/netbsd-doc-print</code></a> for the
10350: PostScript and PDF versions. You will need both packages
10351: installed, to make sure documentation is consistent across all
10352: formats.</p></li>
10353: <li><p>Run <span><strong class="command">cd doc/guide</strong></span> to get to the
10354: right directory. All further steps will take place
10355: here.</p></li>
10356: <li><p>Edit the XML file(s) in
10357: <code class="filename">files/</code>.</p></li>
10358: <li><p>Run <span><strong class="command">bmake</strong></span> to check the pkgsrc
10359: guide for valid XML and to build the final output files. If you
10360: get any errors at this stage, you can just edit the files, as
10361: there are only symbolic links in the working directory, pointing
10362: to the files in <code class="filename">files/</code>.</p></li>
10363: <li><p><span><strong class="command">(cd files && cvs
10364: commit)</strong></span></p></li>
10365: <li><p>Run <span><strong class="command">bmake clean && bmake</strong></span> to
10366: regenerate the output files with the proper RCS
10367: Ids.</p></li>
1.83 wiz 10368: <li><p>Run <span><strong class="command">bmake regenerate</strong></span> to
10369: regenerate the files in both <code class="filename">pkgsrc/doc</code> and
10370: <code class="filename">htdocs</code>.</p></li>
10371: <li><p>If you have added, removed or renamed some chapters,
10372: you need to synchronize them using <span><strong class="command">cvs add</strong></span> or
10373: <span><strong class="command">cvs delete</strong></span> in the htdocs
10374: directory.</p></li>
1.79 rillig 10375: </ol></div>
1.75 rillig 10376: </div>
10377: </div>
10378: </div></body>
1.1 grant 10379: </html>
CVSweb <webmaster@jp.NetBSD.org>