Annotation of htdocs/docs/pkgsrc/using.html, revision 1.49
1.25 sevan 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1.1 dsieger 2: <html>
3: <head>
1.49 ! wiz 4: <meta charset="UTF-8">
1.48 martin 5: <title>Chapter 5. Using pkgsrc</title>
1.12 spz 6: <link rel="stylesheet" type="text/css" href="/global.css">
1.1 dsieger 7: <meta name="generator" content="DocBook XSL Stylesheets VX.X.X">
1.9 rillig 8: <link rel="home" href="index.html" title="The pkgsrc guide">
1.48 martin 9: <link rel="up" href="users-guide.html" title="Part I. The pkgsrc user's guide">
10: <link rel="prev" href="platforms.html" title="Chapter 4. Using pkgsrc on systems other than NetBSD">
11: <link rel="next" href="configuring.html" title="Chapter 6. Configuring pkgsrc">
1.1 dsieger 12: </head>
13: <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14: <div class="navheader">
15: <table width="100%" summary="Navigation header">
1.48 martin 16: <tr><th colspan="3" align="center">Chapter 5. Using pkgsrc</th></tr>
1.1 dsieger 17: <tr>
18: <td width="20%" align="left">
1.48 martin 19: <a accesskey="p" href="platforms.html">Prev</a> </td>
20: <th width="60%" align="center">Part I. The pkgsrc user's guide</th>
21: <td width="20%" align="right"> <a accesskey="n" href="configuring.html">Next</a>
1.1 dsieger 22: </td>
23: </tr>
24: </table>
25: <hr>
26: </div>
1.14 asau 27: <div class="chapter">
1.1 dsieger 28: <div class="titlepage"><div><div><h2 class="title">
1.48 martin 29: <a name="using"></a>Chapter 5. Using pkgsrc</h2></div></div></div>
1.1 dsieger 30: <div class="toc">
31: <p><b>Table of Contents</b></p>
1.22 leot 32: <dl class="toc">
1.33 rillig 33: <dt><span class="sect1"><a href="using.html#using-pkg">5.1. Using binary packages</a></span></dt>
1.1 dsieger 34: <dd><dl>
1.33 rillig 35: <dt><span class="sect2"><a href="using.html#finding-binary-packages">5.1.1. Finding binary packages</a></span></dt>
36: <dt><span class="sect2"><a href="using.html#installing-binary-packages">5.1.2. Installing binary packages</a></span></dt>
1.43 nia 37: <dt><span class="sect2"><a href="using.html#using.pkgin_update">5.1.3. Updating packages</a></span></dt>
38: <dt><span class="sect2"><a href="using.html#using.pkg_delete">5.1.4. Deinstalling packages</a></span></dt>
39: <dt><span class="sect2"><a href="using.html#using.pkg_info">5.1.5. Getting information about installed packages</a></span></dt>
40: <dt><span class="sect2"><a href="using.html#vulnerabilities">5.1.6. Checking for security vulnerabilities in installed packages</a></span></dt>
41: <dt><span class="sect2"><a href="using.html#pkg_versions">5.1.7. Finding if newer versions of your installed packages are in pkgsrc</a></span></dt>
42: <dt><span class="sect2"><a href="using.html#using.pkg_admin">5.1.8. Other administrative functions</a></span></dt>
1.1 dsieger 43: </dl></dd>
1.33 rillig 44: <dt><span class="sect1"><a href="using.html#building-packages-from-source">5.2. Building packages from source</a></span></dt>
1.1 dsieger 45: <dd><dl>
1.33 rillig 46: <dt><span class="sect2"><a href="using.html#requirements">5.2.1. Requirements</a></span></dt>
47: <dt><span class="sect2"><a href="using.html#fetching-distfiles">5.2.2. Fetching distfiles</a></span></dt>
48: <dt><span class="sect2"><a href="using.html#how-to-build-and-install">5.2.3. How to build and install</a></span></dt>
1.1 dsieger 49: </dl></dd>
50: </dl>
51: </div>
52: <p>Basically, there are two ways of using pkgsrc. The first
53: is to only install the package tools and to use binary packages
1.48 martin 54: that someone else has prepared. This is the <span class="quote">“<span class="quote">pkg</span>”</span>
55: in pkgsrc. The second way is to install the <span class="quote">“<span class="quote">src</span>”</span>
1.1 dsieger 56: of pkgsrc, too. Then you are able to build your own packages,
57: and you can still use binary packages from someone else.</p>
1.14 asau 58: <div class="sect1">
1.1 dsieger 59: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.48 martin 60: <a name="using-pkg"></a>5.1. Using binary packages</h2></div></div></div>
1.43 nia 61: <p>On the <a class="ulink" href="https://cdn.NetBSD.org/" target="_top">cdn.NetBSD.org</a>
1.32 sevan 62: site and mirrors, there are collections of binary packages,
1.5 rillig 63: ready to be installed. These binary packages have been built using the
64: default settings for the directories, that is:</p>
1.14 asau 65: <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
1.11 wiz 66: <li class="listitem"><p><code class="filename">/usr/pkg</code> for <code class="varname">LOCALBASE</code>, where most of the files are installed,</p></li>
67: <li class="listitem"><p><code class="filename">/usr/pkg/etc</code> for configuration files,</p></li>
68: <li class="listitem"><p><code class="filename">/var</code> for <code class="varname">VARBASE</code>, where those files are installed that may change after installation.</p></li>
1.5 rillig 69: </ul></div>
70: <p>If you cannot use these directories for whatever reasons (maybe
71: because you're not root), you cannot use these binary packages, but
1.48 martin 72: have to build the packages yourself, which is explained in <a class="xref" href="platforms.html#bootstrapping-pkgsrc" title="4.2. Bootstrapping pkgsrc">Section 4.2, “Bootstrapping pkgsrc”</a>.</p>
1.14 asau 73: <div class="sect2">
1.1 dsieger 74: <div class="titlepage"><div><div><h3 class="title">
1.48 martin 75: <a name="finding-binary-packages"></a>5.1.1. Finding binary packages</h3></div></div></div>
1.4 weinem 76: <p>To install binary packages, you first need to know from where
77: to get them. The first place where you should look is on the main
1.43 nia 78: pkgsrc CDN in the directory <a class="ulink" href="https://cdn.NetBSD.org/pub/pkgsrc/packages/" target="_top"><code class="filename">/pub/pkgsrc/packages</code></a>.</p>
1.4 weinem 79: <p>This directory contains binary packages for multiple
1.45 gutterid 80: platforms. First, select your operating system. Then, select your
81: hardware architecture, and in the third step, the OS version and
1.48 martin 82: the <span class="quote">“<span class="quote">version</span>”</span> of pkgsrc.</p>
1.45 gutterid 83: <p>In this directory, you may find a file called
1.5 rillig 84: <code class="filename">bootstrap.tar.gz</code> which contains the package
85: management tools. If the file is missing, it is likely that your
86: operating system already provides those tools. Download the file and
87: extract it in the <code class="filename">/</code> directory. It will create
88: the directories <code class="filename">/usr/pkg</code> (containing the tools
1.24 sevan 89: for managing binary packages and the database of installed packages).</p>
1.1 dsieger 90: </div>
1.14 asau 91: <div class="sect2">
1.1 dsieger 92: <div class="titlepage"><div><div><h3 class="title">
1.48 martin 93: <a name="installing-binary-packages"></a>5.1.2. Installing binary packages</h3></div></div></div>
1.5 rillig 94: <p>In the directory from the last section, there is a
1.16 wiz 95: subdirectory called <code class="filename">All/</code>, which contains all the
1.5 rillig 96: binary packages that are available for the platform, excluding those
1.43 nia 97: that may not be distributed via HTTP or FTP.</p>
1.5 rillig 98: <p>To install packages directly from an FTP or HTTP server, run
99: the following commands in a Bourne-compatible shell (be sure to
1.6 hubertf 100: <span class="command"><strong>su</strong></span> to root first):</p>
1.5 rillig 101: <pre class="screen">
1.43 nia 102: <code class="prompt">#</code> <strong class="userinput"><code>PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"</code></strong>
103: <code class="prompt">#</code> <strong class="userinput"><code>PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages"</code></strong>
1.38 rillig 104: <code class="prompt">#</code> <strong class="userinput"><code>PKG_PATH="$PKG_PATH/<em class="replaceable"><code>OPSYS</code></em>/<em class="replaceable"><code>ARCH</code></em>/<em class="replaceable"><code>VERSIONS</code></em>/All/"</code></strong>
1.5 rillig 105: <code class="prompt">#</code> <strong class="userinput"><code>export PATH PKG_PATH</code></strong>
1.43 nia 106: <code class="prompt">#</code> <strong class="userinput"><code>pkg_add pkgin</code></strong>
1.5 rillig 107: </pre>
108: <p>Instead of URLs, you can also use local paths, for example if
109: you are installing from a set of CDROMs, DVDs or an NFS-mounted
110: repository. If you want to install packages from multiple sources,
111: you can separate them by a semicolon in
112: <code class="varname">PKG_PATH</code>.</p>
113: <p>After these preparations, installing a package is very
114: easy:</p>
115: <pre class="screen">
1.43 nia 116: <code class="prompt">#</code> <strong class="userinput"><code>pkgin search nginx</code></strong>
117: nginx-1.19.6 Lightweight HTTP server and mail proxy server
118: nginx-1.18.0nb8 Lightweight HTTP server and mail proxy server
119: <code class="prompt">#</code> <strong class="userinput"><code>pkgin install zsh nginx-1.19.6 vim</code></strong>
1.5 rillig 120: </pre>
1.43 nia 121: <p>Note that <span class="command"><strong>pkgin</strong></span> is a user-friendly frontend
122: to the <span class="command"><strong>pkg_*</strong></span> tools.</p>
123: <p>Any prerequisite packages needed to run the
1.1 dsieger 124: package in question will be installed, too, assuming they are
1.43 nia 125: present in the repository.</p>
1.1 dsieger 126: <p>After you've installed packages, be sure to have
127: <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
128: <code class="varname">PATH</code> so you can actually start the just
129: installed program.</p>
130: </div>
1.14 asau 131: <div class="sect2">
1.1 dsieger 132: <div class="titlepage"><div><div><h3 class="title">
1.48 martin 133: <a name="using.pkgin_update"></a>5.1.3. Updating packages</h3></div></div></div>
1.43 nia 134: <p>To update binary packages, it is recommended that you use
135: <span class="command"><strong>pkgin upgrade</strong></span>. This will compare the remote
136: package repository to your locally installed packages and safely
137: replace any older packages.</p>
138: <p>Note that pkgsrc is released as quarterly branches.
139: If you are updating to a newer quarterly branch of pkgsrc, you may
140: need to adjust the repository in
141: <code class="filename">/usr/pkg/etc/pkgin/repositories.conf</code>.</p>
142: </div>
143: <div class="sect2">
144: <div class="titlepage"><div><div><h3 class="title">
1.48 martin 145: <a name="using.pkg_delete"></a>5.1.4. Deinstalling packages</h3></div></div></div>
1.1 dsieger 146: <p>To deinstall a package, it does not matter whether it was
1.43 nia 147: installed from source code or from a binary package. Neither the
148: <span class="command"><strong>pkgin</strong></span> or the <span class="command"><strong>pkg_delete</strong></span>
149: command need to know.</p>
150: <p>To delete a package, you can just run <span class="command"><strong>pkgin remove
1.1 dsieger 151: <em class="replaceable"><code>package-name</code></em></strong></span>. The package
1.43 nia 152: name can be given with or without version number.</p>
1.1 dsieger 153: </div>
1.14 asau 154: <div class="sect2">
1.1 dsieger 155: <div class="titlepage"><div><div><h3 class="title">
1.48 martin 156: <a name="using.pkg_info"></a>5.1.5. Getting information about installed packages</h3></div></div></div>
1.6 hubertf 157: <p>The <span class="command"><strong>pkg_info</strong></span> shows information about
1.43 nia 158: installed packages or binary package files.
159: As with other management tools, it works with packages installed
160: from source or binaries.</p>
1.1 dsieger 161: </div>
1.14 asau 162: <div class="sect2">
1.1 dsieger 163: <div class="titlepage"><div><div><h3 class="title">
1.48 martin 164: <a name="vulnerabilities"></a>5.1.6. Checking for security vulnerabilities in installed packages</h3></div></div></div>
1.1 dsieger 165: <p>
1.35 leot 166: The pkgsrc Security Team and Packages Groups maintain a list of
1.43 nia 167: known vulnerabilities to packages which are (or have been)
1.1 dsieger 168: included in pkgsrc. The list is available from the NetBSD
1.43 nia 169: CDN at <a class="ulink" href="https://cdn.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities" target="_top">https://cdn.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities</a>.
170: </p>
171: <p>
172: Please note that not every "vulnerability" with a CVE assignment is
173: exploitable in every configuration.
174: Some bugs are marked as active simply because an fix was not
175: marked as such.
176: Operating system specific hardening and mitigation features may also
177: reduce the impact of bugs.
1.1 dsieger 178: </p>
179: <p>
1.10 jakllsch 180: Through <span class="command"><strong>pkg_admin fetch-pkg-vulnerabilities</strong></span>,
1.1 dsieger 181: this list can be downloaded
182: automatically, and a security audit of all packages installed on a system
183: can take place.
184: </p>
185: <p>
1.10 jakllsch 186: There are two components to auditing. The first
187: step, <span class="command"><strong>pkg_admin fetch-pkg-vulnerabilities</strong></span>,
188: is for downloading
1.1 dsieger 189: the list of vulnerabilities from the NetBSD FTP site. The second
1.10 jakllsch 190: step, <span class="command"><strong>pkg_admin audit</strong></span>, checks to see if any of your
1.1 dsieger 191: installed packages are vulnerable. If a package is vulnerable, you
192: will see output similar to the following:
193: </p>
194: <pre class="screen">Package samba-2.0.9 has a local-root-shell vulnerability, see
1.39 leot 195: https://www.samba.org/samba/whatsnew/macroexploit.html</pre>
1.1 dsieger 196: <p>
1.10 jakllsch 197: You may wish to have the
1.43 nia 198: <a class="ulink" href="https://cdn.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">vulnerabilities</a>
1.10 jakllsch 199: file downloaded daily so that
200: it remains current. This may be done by adding an appropriate entry
1.47 leot 201: to the root users <a class="citerefentry" href="//man.NetBSD.org/NetBSD-10.1/crontab.5"><span class="citerefentry"><span class="refentrytitle">crontab</span>(5)</span></a> entry. For example the entry
1.10 jakllsch 202: </p>
203: <pre class="screen">
1.26 sevan 204: # Download vulnerabilities file
1.24 sevan 205: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.26 sevan 206: # Audit the installed packages and email results to root
207: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
208: root >/dev/null 2>&1
1.10 jakllsch 209: </pre>
210: <p>
1.24 sevan 211: will update the vulnerability list every day at 3AM, followed by an audit
212: at 3:09AM. The result of the audit are then emailed to root.
1.10 jakllsch 213:
1.24 sevan 214: On NetBSD this may be accomplished instead by adding the following
215: line to <code class="filename">/etc/daily.conf</code>:
1.10 jakllsch 216: </p>
217: <pre class="screen">
1.24 sevan 218: fetch_pkg_vulnerabilities=YES
1.10 jakllsch 219: </pre>
220: <p>
1.24 sevan 221: to fetch the vulnerability list from the daily security script. The system
222: is set to audit the packages by default but can be set explicitly, if
1.27 wiz 223: desired (not required), by adding the following line to
1.24 sevan 224: <code class="filename">/etc/security.conf</code>:
225: </p>
226: <pre class="screen">
227: check_pkg_vulnerabilities=YES
228: </pre>
229: <p>
1.47 leot 230: see <a class="citerefentry" href="//man.NetBSD.org/NetBSD-10.1/daily.conf.5"><span class="citerefentry"><span class="refentrytitle">daily.conf</span>(5)</span></a> and <a class="citerefentry" href="//man.NetBSD.org/NetBSD-10.1/security.conf.5"><span class="citerefentry"><span class="refentrytitle">security.conf</span>(5)</span></a> for more details.
1.1 dsieger 231: </p>
232: </div>
1.14 asau 233: <div class="sect2">
1.1 dsieger 234: <div class="titlepage"><div><div><h3 class="title">
1.48 martin 235: <a name="pkg_versions"></a>5.1.7. Finding if newer versions of your installed packages are in pkgsrc</h3></div></div></div>
1.1 dsieger 236: <p>
1.44 leot 237: Install <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/lintpkgsrc/index.html" target="_top"><code class="filename">pkgtools/lintpkgsrc</code></a> and run
1.48 martin 238: <span class="command"><strong>lintpkgsrc</strong></span> with the <span class="quote">“<span class="quote">-i</span>”</span>
1.43 nia 239: argument to check if any packages are stale, e.g.
1.1 dsieger 240: </p>
241: <pre class="screen">
242: <code class="prompt">%</code> <strong class="userinput"><code>lintpkgsrc -i</code></strong>
243: ...
244: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
245: </pre>
246: </div>
1.14 asau 247: <div class="sect2">
1.1 dsieger 248: <div class="titlepage"><div><div><h3 class="title">
1.48 martin 249: <a name="using.pkg_admin"></a>5.1.8. Other administrative functions</h3></div></div></div>
1.6 hubertf 250: <p>The <span class="command"><strong>pkg_admin</strong></span> executes various
1.1 dsieger 251: administrative functions on the package system.</p>
252: </div>
253: </div>
1.14 asau 254: <div class="sect1">
1.1 dsieger 255: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.48 martin 256: <a name="building-packages-from-source"></a>5.2. Building packages from source</h2></div></div></div>
1.1 dsieger 257: <p>After obtaining pkgsrc, the <code class="filename">pkgsrc</code>
258: directory now contains a set of packages, organized into
259: categories. You can browse the online index of packages, or run
1.6 hubertf 260: <span class="command"><strong>make readme</strong></span> from the <code class="filename">pkgsrc</code>
1.1 dsieger 261: directory to build local <code class="filename">README.html</code> files for
1.44 leot 262: all packages, viewable with any web browser such as <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/lynx/index.html" target="_top"><code class="filename">www/lynx</code></a> or <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/firefox/index.html" target="_top"><code class="filename">www/firefox</code></a>.</p>
1.1 dsieger 263: <p>The default <span class="emphasis"><em>prefix</em></span> for installed packages
264: is <code class="filename">/usr/pkg</code>. If you wish to change this, you
265: should do so by setting <code class="varname">LOCALBASE</code> in
1.6 hubertf 266: <a class="link" href="configuring.html#mk.conf"><code class="filename">mk.conf</code></a>. You should not try to use multiple
1.1 dsieger 267: different <code class="varname">LOCALBASE</code> definitions on the same
268: system (inside a chroot is an exception). </p>
269: <p>The rest of this chapter assumes that the package is already
1.48 martin 270: in pkgsrc. If it is not, see <a class="xref" href="developers-guide.html" title="Part II. The pkgsrc developer's guide">Part II, “The pkgsrc developer's guide”</a> for
1.1 dsieger 271: instructions how to create your own packages.</p>
1.14 asau 272: <div class="sect2">
1.1 dsieger 273: <div class="titlepage"><div><div><h3 class="title">
1.48 martin 274: <a name="requirements"></a>5.2.1. Requirements</h3></div></div></div>
1.1 dsieger 275: <p>To build packages from source, you need a working C
276: compiler. On NetBSD, you need to install the
1.48 martin 277: <span class="quote">“<span class="quote">comp</span>”</span> and the <span class="quote">“<span class="quote">text</span>”</span> distribution
1.1 dsieger 278: sets. If you want to build X11-related packages, the
1.48 martin 279: <span class="quote">“<span class="quote">xbase</span>”</span> and <span class="quote">“<span class="quote">xcomp</span>”</span> distribution
1.1 dsieger 280: sets are required, too.</p>
281: </div>
1.14 asau 282: <div class="sect2">
1.1 dsieger 283: <div class="titlepage"><div><div><h3 class="title">
1.48 martin 284: <a name="fetching-distfiles"></a>5.2.2. Fetching distfiles</h3></div></div></div>
1.1 dsieger 285: <p>The first step for building a package is downloading the
286: distfiles (i.e. the unmodified source). If they have not yet been
287: downloaded, pkgsrc will fetch them automatically.</p>
288: <p>If you have all files that you need in the
289: <code class="filename">distfiles</code> directory,
290: you don't need to connect. If the distfiles are on CD-ROM, you can
291: mount the CD-ROM on <code class="filename">/cdrom</code> and add:
292: </p>
293: <pre class="screen">DISTDIR=/cdrom/pkgsrc/distfiles</pre>
294: <p>
1.6 hubertf 295: to your <a class="link" href="configuring.html#mk.conf"><code class="filename">mk.conf</code></a>.</p>
1.1 dsieger 296: <p>By default a list of distribution sites will be randomly
297: intermixed to prevent huge load on servers which holding popular
298: packages (for example, SourceForge.net mirrors). Thus, every
299: time when you need to fetch yet another distfile all the mirrors
300: will be tried in new (random) order. You can turn this feature
301: off by setting <code class="varname">MASTER_SORT_RANDOM=NO</code> (for
302: <code class="varname">PKG_DEVELOPER</code>s it's already disabled).</p>
303: <p>You can overwrite some of the major distribution sites to
304: fit to sites that are close to your own. By setting one or two
305: variables you can modify the order in which the master sites are
306: accessed. <code class="varname">MASTER_SORT</code> contains a whitespace
307: delimited list of domain suffixes.
308: <code class="varname">MASTER_SORT_REGEX</code> is even more flexible, it
309: contains a whitespace delimited list of regular expressions. It
310: has higher priority than <code class="varname">MASTER_SORT</code>. Have a
311: look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find
312: some examples. This may save some of your bandwidth and
313: time.</p>
314: <p>You can change these settings either in your shell's environment, or,
315: if you want to keep the settings, by editing the
1.6 hubertf 316: <a class="link" href="configuring.html#mk.conf"><code class="filename">mk.conf</code></a> file,
1.1 dsieger 317: and adding the definitions there.</p>
318: <p>
319: If a package depends on many other packages (such as
1.44 leot 320: <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/kde4/index.html" target="_top"><code class="filename">meta-pkgs/kde4</code></a>), the build process may
1.1 dsieger 321: alternate between periods of
322: downloading source, and compiling. To ensure you have all the source
323: downloaded initially you can run the command:
324: </p>
325: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch-list | sh</code></strong></pre>
326: <p>
327: which will output and run a set of shell commands to fetch the
328: necessary files into the <code class="filename">distfiles</code> directory. You can
329: also choose to download the files manually.
330: </p>
331: </div>
1.14 asau 332: <div class="sect2">
1.1 dsieger 333: <div class="titlepage"><div><div><h3 class="title">
1.48 martin 334: <a name="how-to-build-and-install"></a>5.2.3. How to build and install</h3></div></div></div>
1.1 dsieger 335: <p>
336: Once the software has downloaded, any patches will be applied, then it
337: will be compiled for you. This may take some time depending on your
338: computer, and how many other packages the software depends on and their
339: compile time.
340: </p>
1.14 asau 341: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
1.1 dsieger 342: <h3 class="title">Note</h3>
343: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
1.6 hubertf 344: use the pkgsrc <span class="command"><strong>bmake</strong></span> command instead of
1.48 martin 345: <span class="quote">“<span class="quote">make</span>”</span> in the examples in this guide.</p>
1.1 dsieger 346: </div>
347: <p>For example, type</p>
348: <pre class="screen">
349: <code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
350: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
351: </pre>
352: <p>at the shell prompt to build the various components of the
353: package.</p>
354: <p>The next stage is to actually install the newly compiled
355: program onto your system. Do this by entering:
356:
357: </p>
358: <pre class="screen">
359: <code class="prompt">%</code> <strong class="userinput"><code>make install</code></strong>
360: </pre>
361: <p>
362:
363: while you are still in the directory for whatever package you
364: are installing.</p>
365: <p>Installing the package on your system may require you to
366: be root. However, pkgsrc has a
367: <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
368: to only become root for the actual installation step.</p>
369: <p>That's it, the software should now be installed and setup for use.
370: You can now enter:
371:
372: </p>
373: <pre class="screen">
374: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong>
375: </pre>
376: <p>
377:
378: to remove the compiled files in the work directory, as you shouldn't need
379: them any more. If other packages were also added to your system
380: (dependencies) to allow your program to compile, you can tidy these up
381: also with the command:</p>
382: <pre class="screen">
383: <code class="prompt">%</code> <strong class="userinput"><code>make clean-depends</code></strong>
384: </pre>
385: <p>Taking the figlet utility as an example, we can install it on our
1.48 martin 386: system by building as shown in <a class="xref" href="logs.html" title="Appendix C. Build logs">Appendix C, <i>Build logs</i></a>.</p>
1.1 dsieger 387: <p>The program is installed under the default root of the
388: packages tree - <code class="filename">/usr/pkg</code>. Should this not
389: conform to your tastes, set the <code class="varname">LOCALBASE</code>
390: variable in your environment, and it will use that value as the
391: root of your packages tree. So, to use
392: <code class="filename">/usr/local</code>, set
393: <code class="varname">LOCALBASE=/usr/local</code> in your environment.
394: Please note that you should use a directory which is dedicated to
395: packages and not shared with other programs (i.e., do not try and
396: use <code class="varname">LOCALBASE=/usr</code>). Also, you should not try
397: to add any of your own files or directories (such as
398: <code class="filename">src/</code>, <code class="filename">obj/</code>, or
399: <code class="filename">pkgsrc/</code>) below the
400: <code class="varname">LOCALBASE</code> tree. This is to prevent possible
401: conflicts between programs and other files installed by the
402: package system and whatever else may have been installed
403: there.</p>
1.6 hubertf 404: <p>Some packages look in <a class="link" href="configuring.html#mk.conf"><code class="filename">mk.conf</code></a> to
1.1 dsieger 405: alter some configuration options at build time. Have a look at
406: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to get an overview
407: of what will be set there by default. Environment variables such
408: as <code class="varname">LOCALBASE</code> can be set in
1.6 hubertf 409: <a class="link" href="configuring.html#mk.conf"><code class="filename">mk.conf</code></a> to save having to remember to
1.1 dsieger 410: set them each time you want to use pkgsrc.</p>
1.48 martin 411: <p>Occasionally, people want to <span class="quote">“<span class="quote">look under the
412: covers</span>”</span> to see what is going on when a package is building
1.1 dsieger 413: or being installed. This may be for debugging purposes, or out of
414: simple curiosity. A number of utility values have been added to
415: help with this.</p>
1.11 wiz 416: <div class="orderedlist"><ol class="orderedlist" type="1">
417: <li class="listitem">
1.47 leot 418: <p>If you invoke the <a class="citerefentry" href="//man.NetBSD.org/NetBSD-10.1/make.1"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a> command with
1.1 dsieger 419: <code class="varname">PKG_DEBUG_LEVEL=2</code>, then a huge amount of
420: information will be displayed. For example,</p>
421: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
422: <p>will show all the commands that are invoked, up to and
1.48 martin 423: including the <span class="quote">“<span class="quote">patch</span>”</span> stage.</p>
1.1 dsieger 424: </li>
1.11 wiz 425: <li class="listitem">
1.47 leot 426: <p>If you want to know the value of a certain <a class="citerefentry" href="//man.NetBSD.org/NetBSD-10.1/make.1"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>
1.1 dsieger 427: definition, then the <code class="varname">VARNAME</code> definition
428: should be used, in conjunction with the show-var
1.47 leot 429: target. e.g. to show the expansion of the <a class="citerefentry" href="//man.NetBSD.org/NetBSD-10.1/make.1"><span class="citerefentry"><span class="refentrytitle">make</span>(1)</span></a>
1.1 dsieger 430: variable <code class="varname">LOCALBASE</code>:</p>
431: <pre class="screen">
432: <code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
433: /usr/pkg
434: <code class="prompt">%</code>
435: </pre>
436: </li>
437: </ol></div>
438: <p>If you want to install a binary package that you've either
439: created yourself (see next section), that you put into
440: pkgsrc/packages manually or that is located on a remote FTP
441: server, you can use the "bin-install" target. This target will
1.47 leot 442: install a binary package - if available - via <a class="citerefentry" href="//man.NetBSD.org/NetBSD-10.1/pkg_add.1"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>,
1.6 hubertf 443: else do a <span class="command"><strong>make package</strong></span>. The list of remote FTP
1.1 dsieger 444: sites searched is kept in the variable
445: <code class="varname">BINPKG_SITES</code>, which defaults to
1.47 leot 446: ftp.NetBSD.org. Any flags that should be added to <a class="citerefentry" href="//man.NetBSD.org/NetBSD-10.1/pkg_add.1"><span class="citerefentry"><span class="refentrytitle">pkg_add</span>(1)</span></a>
1.1 dsieger 447: can be put into <code class="varname">BIN_INSTALL_FLAGS</code>. See
448: <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more
449: details.</p>
450: <p>A final word of warning: If you set up a system that has a
451: non-standard setting for <code class="varname">LOCALBASE</code>, be sure to
452: set that before any packages are installed, as you cannot use
453: several directories for the same purpose. Doing so will result in
454: pkgsrc not being able to properly detect your installed packages,
455: and fail miserably. Note also that precompiled binary packages are
456: usually built with the default <code class="varname">LOCALBASE</code> of
457: <code class="filename">/usr/pkg</code>, and that you should
458: <span class="emphasis"><em>not</em></span> install any if you use a non-standard
459: <code class="varname">LOCALBASE</code>.</p>
460: </div>
461: </div>
462: </div>
463: <div class="navfooter">
464: <hr>
465: <table width="100%" summary="Navigation footer">
466: <tr>
467: <td width="40%" align="left">
1.48 martin 468: <a accesskey="p" href="platforms.html">Prev</a> </td>
1.1 dsieger 469: <td width="20%" align="center"><a accesskey="u" href="users-guide.html">Up</a></td>
1.48 martin 470: <td width="40%" align="right"> <a accesskey="n" href="configuring.html">Next</a>
1.1 dsieger 471: </td>
472: </tr>
473: <tr>
1.48 martin 474: <td width="40%" align="left" valign="top">Chapter 4. Using pkgsrc on systems other than NetBSD </td>
1.1 dsieger 475: <td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
1.48 martin 476: <td width="40%" align="right" valign="top"> Chapter 6. Configuring pkgsrc</td>
1.1 dsieger 477: </tr>
478: </table>
479: </div>
480: </body>
481: </html>
CVSweb <webmaster@jp.NetBSD.org>