Annotation of htdocs/docs/pkgsrc/using.html, revision 1.4

1.1       dsieger     1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
                      2: <html>
                      3: <head>
                      4: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
                      5: <title>Chapter 4. Using pkgsrc</title>
1.2       rillig      6: <link rel="stylesheet" href="/global.css" type="text/css">
1.1       dsieger     7: <meta name="generator" content="DocBook XSL Stylesheets VX.X.X">
                      8: <link rel="start" href="index.html" title="The pkgsrc guide">
                      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>
                     27: <div class="chapter" lang="en">
                     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>
                     32: <dl>
                     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: <dt><span class="sect2"><a href="using.html#a-word-of-warning">4.1.8. A word of warning</a></span></dt>
                     43: </dl></dd>
                     44: <dt><span class="sect1"><a href="using.html#building-packages-from-source">4.2. Building packages from source</a></span></dt>
                     45: <dd><dl>
                     46: <dt><span class="sect2"><a href="using.html#requirements">4.2.1. Requirements</a></span></dt>
                     47: <dt><span class="sect2"><a href="using.html#fetching-distfiles">4.2.2. Fetching distfiles</a></span></dt>
                     48: <dt><span class="sect2"><a href="using.html#how-to-build-and-install">4.2.3. How to build and install</a></span></dt>
                     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
                     54: that someone else has prepared. This is the &#8220;<span class="quote">pkg</span>&#8221;
                     55: in pkgsrc. The second way is to install the &#8220;<span class="quote">src</span>&#8221;
                     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>
                     58: <div class="sect1" lang="en">
                     59: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                     60: <a name="using-pkg"></a>4.1. Using binary packages</h2></div></div></div>
1.4     ! weinem     61: <p>To use binary packages, you need some tools to manage them. On
        !            62:   NetBSD, these tools are already installed. On all other operating
        !            63:   systems, you need to install them first. For some platforms, these
        !            64:   tools are already packages in an archive, ready to be extracted in the
        !            65:   <code class="filename">/</code> directory. They can be found in the <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/bootstrap-pkgsrc" target="_top"><code class="filename">bootstrap-pkgsrc</code></a>
        !            66:   directory of the FTP server.</p>
1.1       dsieger    67: <p>These pre-built package tools use
                     68:   <code class="filename">/usr/pkg</code> for the base directory, and
                     69:   <code class="filename">/var/db/pkg</code> for the database of installed
                     70:   packages. If you cannot use these directories for whatever
                     71:   reasons (maybe because you're not root), you have to build the
                     72:   package tools yourself, which is explained in <a href="platforms.html#bootstrapping-pkgsrc" title="3.2. Bootstrapping pkgsrc">Section 3.2, &#8220;Bootstrapping pkgsrc&#8221;</a>.</p>
                     73: <div class="sect2" lang="en">
                     74: <div class="titlepage"><div><div><h3 class="title">
                     75: <a name="finding-binary-packages"></a>4.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
        !            78:     pkgsrc FTP server in the directory <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/packages/" target="_top"><code class="filename">/pub/pkgsrc/packages</code></a>.</p>
        !            79: <p>This directory contains binary packages for multiple
        !            80:     platforms. First, select your operating system. (Ignore the
        !            81:     directories with version numbers attached to it, they just exist for
        !            82:     legacy reasons.) Then, select your hardware architecture, and in the
        !            83:     third step, the OS version and the &#8220;<span class="quote">version</span>&#8221; of pkgsrc.
        !            84:     This directory contains a subdirectory called
        !            85:     <code class="filename">All</code>, where (almost) all binary packages are
        !            86:     stored. Almost, because vulnerable packages are moved to the
        !            87:     <code class="filename">vulnerable</code> directory so they don't get
        !            88:     installed accidentally.</p>
1.1       dsieger    89: </div>
                     90: <div class="sect2" lang="en">
                     91: <div class="titlepage"><div><div><h3 class="title">
                     92: <a name="installing-binary-packages"></a>4.1.2. Installing binary packages</h3></div></div></div>
                     93: <p>If you have the files on a CD-ROM or downloaded them to
                     94:     your hard disk, you can install them with the following command
                     95:     (be sure to <span><strong class="command">su</strong></span> to root first):</p>
                     96: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add /path/to/package.tgz</code></strong></pre>
                     97: <p>If you have FTP access and you don't want to download the
                     98:     packages via FTP prior to installation, you can do this
                     99:     automatically by giving <span><strong class="command">pkg_add</strong></span> an FTP URL:</p>
1.4     ! weinem    100: <pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>pkg_add 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/<em class="replaceable"><code>package</code></em></code></strong></pre>
1.1       dsieger   101: <p>Note that any prerequisite packages needed to run the
                    102:     package in question will be installed, too, assuming they are
                    103:     present where you install from.</p>
                    104: <p>To save some typing, you can set the
                    105:     <code class="varname">PKG_PATH</code> environment variable to a semicolon-separated
                    106:     list of paths (including remote URLs); trailing slashes are not allowed.
                    107:     </p>
                    108: <p>Additionally to the <code class="filename">All</code> directory
                    109:     there exists a <code class="filename">vulnerable</code> directory to
                    110:     which binary packages with known vulnerabilities are
                    111:     moved, since removing them could cause missing dependencies. To
                    112:     use these packages, add the <code class="filename">vulnerable</code>
                    113:     directory to your <code class="varname">PKG_PATH</code>. However, you should run
                    114:     <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a> regularly,
                    115:     especially after installing new packages, and verify that the
                    116:     vulnerabilities are acceptable for your configuration. An example
                    117:     <code class="varname">PKG_PATH</code> would be:
                    118:     <code class="filename">ftp://ftp.NetBSD.org/pub/NetBSD/packages/&lt;OSVERSION&gt;/&lt;ARCH&gt;/All;ftp://ftp.NetBSD.org/pub/NetBSD/packages/&lt;OSVERSION&gt;/&lt;ARCH&gt;/vulnerable</code>
                    119:     Please note that semicolon (';') is a shell meta-character, so
                    120:     you'll probably have to quote it.</p>
                    121: <p>After you've installed packages, be sure to have
                    122:     <code class="filename">/usr/pkg/bin</code> and <code class="filename">/usr/pkg/sbin</code> in your
                    123:     <code class="varname">PATH</code> so you can actually start the just
                    124:     installed program.</p>
                    125: </div>
                    126: <div class="sect2" lang="en">
                    127: <div class="titlepage"><div><div><h3 class="title">
                    128: <a name="using.pkg_delete"></a>4.1.3. Deinstalling packages</h3></div></div></div>
                    129: <p>To deinstall a package, it does not matter whether it was
                    130:     installed from source code or from a binary package. The
                    131:     <span><strong class="command">pkg_delete</strong></span> command does not know it anyway.
                    132:     To delete a package, you can just run <span><strong class="command">pkg_delete
                    133:     <em class="replaceable"><code>package-name</code></em></strong></span>. The package
                    134:     name can be given with or without version number. Wildcards can
                    135:     also be used to deinstall a set of packages, for example
                    136:     <code class="literal">*emacs*</code>. Be sure to include them in quotes,
                    137:     so that the shell does not expand them before
                    138:     <code class="literal">pkg_delete</code> sees them.</p>
                    139: <p>The <code class="option">-r</code> option is very powerful: it
                    140:     removes all the packages that require the package in question
                    141:     and then removes the package itself. For example:
                    142: 
                    143:     </p>
                    144: <pre class="screen">
                    145: <code class="prompt">#</code> <strong class="userinput"><code>pkg_delete -r jpeg</code></strong>
                    146:     </pre>
                    147: <p>
                    148: 
                    149:     will remove jpeg and all the packages that used it; this allows
                    150:     upgrading the jpeg package.</p>
                    151: </div>
                    152: <div class="sect2" lang="en">
                    153: <div class="titlepage"><div><div><h3 class="title">
                    154: <a name="using.pkg_info"></a>4.1.4. Getting information about installed packages</h3></div></div></div>
                    155: <p>The <span><strong class="command">pkg_info</strong></span> shows information about
                    156:     installed packages or binary package files.</p>
                    157: </div>
                    158: <div class="sect2" lang="en">
                    159: <div class="titlepage"><div><div><h3 class="title">
                    160: <a name="vulnerabilities"></a>4.1.5. Checking for security vulnerabilities in installed packages</h3></div></div></div>
                    161: <p>
                    162:       The NetBSD Security-Officer and Packages Groups maintain a list of
                    163:       known security vulnerabilities to packages which are (or have been)
                    164:       included in pkgsrc.  The list is available from the NetBSD
                    165:       FTP site at <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities</a>.
                    166:     </p>
                    167: <p>
                    168:       Through <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>,
                    169:       this list can be downloaded
                    170:       automatically, and a security audit of all packages installed on a system
                    171:       can take place.
                    172:     </p>
                    173: <p>
                    174:       There are two components to
                    175:       <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>.  The first
                    176:       component, &#8220;<span class="quote">download-vulnerability-list</span>&#8221;, is for downloading
                    177:       the list of vulnerabilities from the NetBSD FTP site.  The second
                    178:       component, &#8220;<span class="quote">audit-packages</span>&#8221;, checks to see if any of your
                    179:       installed packages are vulnerable.  If a package is vulnerable, you
                    180:       will see output similar to the following:
                    181:     </p>
                    182: <pre class="screen">Package samba-2.0.9 has a local-root-shell vulnerability, see
                    183:     http://www.samba.org/samba/whatsnew/macroexploit.html</pre>
                    184: <p>
                    185:       One can set up <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a> to download the
                    186:       <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/vulnerabilities" target="_top">vulnerabilities</a>
                    187:       file daily, and include a package audit in the daily security script.
                    188:       Details on this are located in the <a href="http://cvsweb.NetBSD.org/bsdweb.cgi/pkgsrc/security/audit-packages/MESSAGE?rev=HEAD&amp;content-type=text/x-cvsweb-markup" target="_top">MESSAGE</a>
                    189:       file for <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/security/audit-packages/README.html" target="_top"><code class="filename">security/audit-packages</code></a>.
                    190:     </p>
                    191: </div>
                    192: <div class="sect2" lang="en">
                    193: <div class="titlepage"><div><div><h3 class="title">
                    194: <a name="pkg_versions"></a>4.1.6. Finding if newer versions of your installed packages are in pkgsrc</h3></div></div></div>
                    195: <p>
                    196:       Install <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/README.html" target="_top"><code class="filename">pkgtools/pkglint</code></a> and run
                    197:       <span><strong class="command">lintpkgsrc</strong></span> with the &#8220;<span class="quote">-i</span>&#8221;
                    198:       argument to check if your packages are up-to-date, e.g.
                    199:     </p>
                    200: <pre class="screen">
                    201: <code class="prompt">%</code> <strong class="userinput"><code>lintpkgsrc -i</code></strong>
                    202: ...
                    203: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
                    204:     </pre>
                    205: <p>You can then use <span><strong class="command">make update</strong></span> to update the
                    206:     package on your system and rebuild any dependencies.
                    207:     </p>
                    208: </div>
                    209: <div class="sect2" lang="en">
                    210: <div class="titlepage"><div><div><h3 class="title">
                    211: <a name="using.pkg_admin"></a>4.1.7. Other administrative functions</h3></div></div></div>
                    212: <p>The <span><strong class="command">pkg_admin</strong></span> executes various
                    213:     administrative functions on the package system.</p>
                    214: </div>
                    215: <div class="sect2" lang="en">
                    216: <div class="titlepage"><div><div><h3 class="title">
                    217: <a name="a-word-of-warning"></a>4.1.8. A word of warning</h3></div></div></div>
                    218: <p>Please pay very careful attention to the warnings
                    219:     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
                    220:     inherent dangers of installing binary packages which you did
                    221:     not create yourself, and the security holes that can be
                    222:     introduced onto your system by indiscriminate adding of such
                    223:     files.</p>
                    224: <p>The same warning of course applies to every package you
                    225:     install from source when you haven't completely read and
                    226:     understood the source code of the package, the compiler that
                    227:     is used to build the package and all the other tools that are
                    228:     involved.</p>
                    229: </div>
                    230: </div>
                    231: <div class="sect1" lang="en">
                    232: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
                    233: <a name="building-packages-from-source"></a>4.2. Building packages from source</h2></div></div></div>
                    234: <p>After obtaining pkgsrc, the <code class="filename">pkgsrc</code>
                    235:   directory now contains a set of packages, organized into
                    236:   categories. You can browse the online index of packages, or run
                    237:   <span><strong class="command">make readme</strong></span> from the <code class="filename">pkgsrc</code>
                    238:   directory to build local <code class="filename">README.html</code> files for
                    239:   all packages, viewable with any web browser such as <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/lynx/README.html" target="_top"><code class="filename">www/lynx</code></a> or <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/firefox/README.html" target="_top"><code class="filename">www/firefox</code></a>.</p>
                    240: <p>The default <span class="emphasis"><em>prefix</em></span> for installed packages
                    241:   is <code class="filename">/usr/pkg</code>. If you wish to change this, you
                    242:   should do so by setting <code class="varname">LOCALBASE</code> in
1.3       rillig    243:   <a href="configuring.html#mk.conf"><code class="filename">mk.conf</code></a>. You should not try to use multiple
1.1       dsieger   244:   different <code class="varname">LOCALBASE</code> definitions on the same
                    245:   system (inside a chroot is an exception). </p>
                    246: <p>The rest of this chapter assumes that the package is already
                    247:   in pkgsrc. If it is not, see <a href="developers-guide.html" title="Part II. The pkgsrc developer's guide">Part II, &#8220;The pkgsrc developer's guide&#8221;</a> for
                    248:   instructions how to create your own packages.</p>
                    249: <div class="sect2" lang="en">
                    250: <div class="titlepage"><div><div><h3 class="title">
                    251: <a name="requirements"></a>4.2.1. Requirements</h3></div></div></div>
                    252: <p>To build packages from source, you need a working C
                    253:     compiler. On NetBSD, you need to install the
                    254:     &#8220;<span class="quote">comp</span>&#8221; and the &#8220;<span class="quote">text</span>&#8221; distribution
                    255:     sets. If you want to build X11-related packages, the
                    256:     &#8220;<span class="quote">xbase</span>&#8221; and &#8220;<span class="quote">xcomp</span>&#8221; distribution
                    257:     sets are required, too.</p>
                    258: </div>
                    259: <div class="sect2" lang="en">
                    260: <div class="titlepage"><div><div><h3 class="title">
                    261: <a name="fetching-distfiles"></a>4.2.2. Fetching distfiles</h3></div></div></div>
                    262: <p>The first step for building a package is downloading the
                    263:     distfiles (i.e. the unmodified source). If they have not yet been
                    264:     downloaded, pkgsrc will fetch them automatically.</p>
                    265: <p>If you have all files that you need in the
                    266:     <code class="filename">distfiles</code> directory,
                    267:     you don't need to connect. If the distfiles are on CD-ROM, you can
                    268:     mount the CD-ROM on <code class="filename">/cdrom</code> and add:
                    269:     </p>
                    270: <pre class="screen">DISTDIR=/cdrom/pkgsrc/distfiles</pre>
                    271: <p>
1.3       rillig    272:     to your <a href="configuring.html#mk.conf"><code class="filename">mk.conf</code></a>.</p>
1.1       dsieger   273: <p>By default a list of distribution sites will be randomly
                    274:     intermixed to prevent huge load on servers which holding popular
                    275:     packages (for example, SourceForge.net mirrors). Thus, every
                    276:     time when you need to fetch yet another distfile all the mirrors
                    277:     will be tried in new (random) order. You can turn this feature
                    278:     off by setting <code class="varname">MASTER_SORT_RANDOM=NO</code> (for
                    279:     <code class="varname">PKG_DEVELOPER</code>s it's already disabled).</p>
                    280: <p>You can overwrite some of the major distribution sites to
                    281:     fit to sites that are close to your own.  By setting one or two
                    282:     variables you can modify the order in which the master sites are
                    283:     accessed.  <code class="varname">MASTER_SORT</code> contains a whitespace
                    284:     delimited list of domain suffixes.
                    285:     <code class="varname">MASTER_SORT_REGEX</code> is even more flexible, it
                    286:     contains a whitespace delimited list of regular expressions.  It
                    287:     has higher priority than <code class="varname">MASTER_SORT</code>.  Have a
                    288:     look at <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to find
                    289:     some examples.  This may save some of your bandwidth and
                    290:     time.</p>
                    291: <p>You can change these settings either in your shell's environment, or,
                    292:     if you want to keep the settings, by editing the
1.3       rillig    293:     <a href="configuring.html#mk.conf"><code class="filename">mk.conf</code></a> file,
1.1       dsieger   294:     and adding the definitions there.</p>
                    295: <p>
                    296:       If a package depends on many other packages (such as
                    297:       <a href="ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/kde3/README.html" target="_top"><code class="filename">meta-pkgs/kde3</code></a>), the build process may
                    298:       alternate between periods of
                    299:       downloading source, and compiling. To ensure you have all the source
                    300:       downloaded initially you can run the command:
                    301:       </p>
                    302: <pre class="screen"><code class="prompt">%</code> <strong class="userinput"><code>make fetch-list | sh</code></strong></pre>
                    303: <p>
                    304:       which will output and run a set of shell commands to fetch the
                    305:       necessary files into the <code class="filename">distfiles</code> directory.  You can
                    306:       also choose to download the files manually.
                    307:     </p>
                    308: </div>
                    309: <div class="sect2" lang="en">
                    310: <div class="titlepage"><div><div><h3 class="title">
                    311: <a name="how-to-build-and-install"></a>4.2.3. How to build and install</h3></div></div></div>
                    312: <p>
                    313:       Once the software has downloaded, any patches will be applied, then it
                    314:       will be compiled for you. This may take some time depending on your
                    315:       computer, and how many other packages the software depends on and their
                    316:       compile time.
                    317:     </p>
                    318: <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
                    319: <h3 class="title">Note</h3>
                    320: <p>If using bootstrap or pkgsrc on a non-NetBSD system,
                    321:     use the pkgsrc <span><strong class="command">bmake</strong></span> command instead of
                    322:     &#8220;<span class="quote">make</span>&#8221; in the examples in this guide.</p>
                    323: </div>
                    324: <p>For example, type</p>
                    325: <pre class="screen">
                    326: <code class="prompt">%</code> <strong class="userinput"><code>cd misc/figlet</code></strong>
                    327: <code class="prompt">%</code> <strong class="userinput"><code>make</code></strong>
                    328:     </pre>
                    329: <p>at the shell prompt to build the various components of the
                    330:     package.</p>
                    331: <p>The next stage is to actually install the newly compiled
                    332:     program onto your system. Do this by entering:
                    333: 
                    334:     </p>
                    335: <pre class="screen">
                    336: <code class="prompt">%</code> <strong class="userinput"><code>make install</code></strong>
                    337:     </pre>
                    338: <p>
                    339: 
                    340:     while you are still in the directory for whatever package you
                    341:     are installing.</p>
                    342: <p>Installing the package on your system may require you to
                    343:     be root.  However, pkgsrc has a
                    344:     <span class="emphasis"><em>just-in-time-su</em></span> feature, which allows you
                    345:     to only become root for the actual installation step.</p>
                    346: <p>That's it, the software should now be installed and setup for use.
                    347:     You can now enter:
                    348: 
                    349:     </p>
                    350: <pre class="screen">
                    351: <code class="prompt">%</code> <strong class="userinput"><code>make clean</code></strong>
                    352:     </pre>
                    353: <p>
                    354: 
                    355:     to remove the compiled files in the work directory, as you shouldn't need
                    356:     them any more. If other packages were also added to your system
                    357:     (dependencies) to allow your program to compile, you can tidy these up
                    358:     also with the command:</p>
                    359: <pre class="screen">
                    360: <code class="prompt">%</code> <strong class="userinput"><code>make clean-depends</code></strong>
                    361:     </pre>
                    362: <p>Taking the figlet utility as an example, we can install it on our
                    363:     system by building as shown in <a href="logs.html" title="Appendix B. Build logs">Appendix B, <i>Build logs</i></a>.</p>
                    364: <p>The program is installed under the default root of the
                    365:     packages tree - <code class="filename">/usr/pkg</code>. Should this not
                    366:     conform to your tastes, set the <code class="varname">LOCALBASE</code>
                    367:     variable in your environment, and it will use that value as the
                    368:     root of your packages tree. So, to use
                    369:     <code class="filename">/usr/local</code>, set
                    370:     <code class="varname">LOCALBASE=/usr/local</code> in your environment.
                    371:     Please note that you should use a directory which is dedicated to
                    372:     packages and not shared with other programs (i.e., do not try and
                    373:     use <code class="varname">LOCALBASE=/usr</code>).  Also, you should not try
                    374:     to add any of your own files or directories (such as
                    375:     <code class="filename">src/</code>, <code class="filename">obj/</code>, or
                    376:     <code class="filename">pkgsrc/</code>) below the
                    377:     <code class="varname">LOCALBASE</code> tree.  This is to prevent possible
                    378:     conflicts between programs and other files installed by the
                    379:     package system and whatever else may have been installed
                    380:     there.</p>
1.3       rillig    381: <p>Some packages look in <a href="configuring.html#mk.conf"><code class="filename">mk.conf</code></a> to
1.1       dsieger   382:     alter some configuration options at build time.  Have a look at
                    383:     <code class="filename">pkgsrc/mk/defaults/mk.conf</code> to get an overview
                    384:     of what will be set there by default.  Environment variables such
                    385:     as <code class="varname">LOCALBASE</code> can be set in
1.3       rillig    386:     <a href="configuring.html#mk.conf"><code class="filename">mk.conf</code></a> to save having to remember to
1.1       dsieger   387:     set them each time you want to use pkgsrc.</p>
                    388: <p>Occasionally, people want to &#8220;<span class="quote">look under the
                    389:     covers</span>&#8221; to see what is going on when a package is building
                    390:     or being installed. This may be for debugging purposes, or out of
                    391:     simple curiosity. A number of utility values have been added to
                    392:     help with this.</p>
                    393: <div class="orderedlist"><ol type="1">
                    394: <li>
                    395: <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
                    396:        <code class="varname">PKG_DEBUG_LEVEL=2</code>, then a huge amount of
                    397:        information will be displayed. For example,</p>
                    398: <pre class="screen"><strong class="userinput"><code>make patch PKG_DEBUG_LEVEL=2</code></strong></pre>
                    399: <p>will show all the commands that are invoked, up to and
                    400:        including the &#8220;<span class="quote">patch</span>&#8221; stage.</p>
                    401: </li>
                    402: <li>
                    403: <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>
                    404:        definition, then the <code class="varname">VARNAME</code> definition
                    405:        should be used, in conjunction with the show-var
                    406:        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>
                    407:        variable <code class="varname">LOCALBASE</code>:</p>
                    408: <pre class="screen">
                    409: <code class="prompt">%</code> <strong class="userinput"><code>make show-var VARNAME=LOCALBASE</code></strong>
                    410: /usr/pkg
                    411: <code class="prompt">%</code>
                    412:        </pre>
                    413: </li>
                    414: </ol></div>
                    415: <p>If you want to install a binary package that you've either
                    416:     created yourself (see next section), that you put into
                    417:     pkgsrc/packages manually or that is located on a remote FTP
                    418:     server, you can use the "bin-install" target. This target will
                    419:     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>,
                    420:     else do a <span><strong class="command">make package</strong></span>.  The list of remote FTP
                    421:     sites searched is kept in the variable
                    422:     <code class="varname">BINPKG_SITES</code>, which defaults to
                    423:     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>
                    424:     can be put into <code class="varname">BIN_INSTALL_FLAGS</code>.  See
                    425:     <code class="filename">pkgsrc/mk/defaults/mk.conf</code> for more
                    426:     details.</p>
                    427: <p>A final word of warning: If you set up a system that has a
                    428:     non-standard setting for <code class="varname">LOCALBASE</code>, be sure to
                    429:     set that before any packages are installed, as you cannot use
                    430:     several directories for the same purpose. Doing so will result in
                    431:     pkgsrc not being able to properly detect your installed packages,
                    432:     and fail miserably. Note also that precompiled binary packages are
                    433:     usually built with the default <code class="varname">LOCALBASE</code> of
                    434:     <code class="filename">/usr/pkg</code>, and that you should
                    435:     <span class="emphasis"><em>not</em></span> install any if you use a non-standard
                    436:     <code class="varname">LOCALBASE</code>.</p>
                    437: </div>
                    438: </div>
                    439: </div>
                    440: <div class="navfooter">
                    441: <hr>
                    442: <table width="100%" summary="Navigation footer">
                    443: <tr>
                    444: <td width="40%" align="left">
                    445: <a accesskey="p" href="platforms.html">Prev</a> </td>
                    446: <td width="20%" align="center"><a accesskey="u" href="users-guide.html">Up</a></td>
                    447: <td width="40%" align="right"> <a accesskey="n" href="configuring.html">Next</a>
                    448: </td>
                    449: </tr>
                    450: <tr>
                    451: <td width="40%" align="left" valign="top">Chapter 3. Using pkgsrc on systems other than NetBSD </td>
                    452: <td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
                    453: <td width="40%" align="right" valign="top"> Chapter 5. Configuring pkgsrc</td>
                    454: </tr>
                    455: </table>
                    456: </div>
                    457: </body>
                    458: </html>

CVSweb <webmaster@jp.NetBSD.org>