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