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