git: ff3df39394 - main - a67af5a97b -> e633f0b9df
Ryusuke SUZUKI
ryusuke at FreeBSD.org
Sat May 1 16:54:35 UTC 2021
The branch main has been updated by ryusuke:
URL: https://cgit.FreeBSD.org/doc/commit/?id=ff3df39394cc4faf4300a4b19954f93a0fd46868
commit ff3df39394cc4faf4300a4b19954f93a0fd46868
Author: Ryusuke SUZUKI <ryusuke at FreeBSD.org>
AuthorDate: 2021-05-01 16:51:45 +0000
Commit: Ryusuke SUZUKI <ryusuke at FreeBSD.org>
CommitDate: 2021-05-01 16:51:45 +0000
a67af5a97b -> e633f0b9df
---
en_US.ISO8859-1/books/handbook/ports/chapter.xml | 1831 ++++++++++++++++++++++
website/data/ja/news/news.toml | 8 +
2 files changed, 1839 insertions(+)
diff --git a/en_US.ISO8859-1/books/handbook/ports/chapter.xml b/en_US.ISO8859-1/books/handbook/ports/chapter.xml
new file mode 100644
index 0000000000..110d47f3b6
--- /dev/null
+++ b/en_US.ISO8859-1/books/handbook/ports/chapter.xml
@@ -0,0 +1,1831 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!--
+ The FreeBSD Documentation Project
+
+ $FreeBSD$
+-->
+<chapter xmlns="http://docbook.org/ns/docbook"
+ xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0"
+ xml:id="ports">
+
+ <title>Installing Applications: Packages and Ports</title>
+
+ <sect1 xml:id="ports-synopsis">
+ <title>Synopsis</title>
+
+ <indexterm><primary>ports</primary></indexterm>
+ <indexterm><primary>packages</primary></indexterm>
+ <para>&os; is bundled with a rich collection of system tools as
+ part of the base system. In addition, &os; provides two
+ complementary technologies for installing third-party software:
+ the &os; Ports Collection, for installing from source, and
+ packages, for installing from pre-built binaries. Either
+ method may be used to install software from local media or
+ from the network.</para>
+
+ <para>After reading this chapter, you will know:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>The difference between binary packages and ports.</para>
+ </listitem>
+
+ <listitem>
+ <para>How to find third-party software that has been ported
+ to &os;.</para>
+ </listitem>
+
+ <listitem>
+ <para>How to manage binary packages using
+ <application>pkg</application>.</para>
+ </listitem>
+
+ <listitem>
+ <para>How to build third-party software from source using the
+ Ports Collection.</para>
+ </listitem>
+
+ <listitem>
+ <para>How to find the files installed with the application
+ for post-installation configuration.</para>
+ </listitem>
+
+ <listitem>
+ <para>What to do if a software installation fails.</para>
+ </listitem>
+ </itemizedlist>
+ </sect1>
+
+ <sect1 xml:id="ports-overview">
+ <title>Overview of Software Installation</title>
+
+ <para>The typical steps for installing third-party software on a
+ &unix; system include:</para>
+
+ <procedure>
+ <step>
+ <para>Find and download the software, which might be
+ distributed in source code format or as a binary.</para>
+ </step>
+
+ <step>
+ <para>Unpack the software from its distribution format. This
+ is typically a tarball compressed with a program such as
+ &man.compress.1;, &man.gzip.1;, &man.bzip2.1; or
+ &man.xz.1;.</para>
+ </step>
+
+ <step>
+ <para>Locate the documentation in
+ <filename>INSTALL</filename>, <filename>README</filename>
+ or some file in a <filename>doc/</filename> subdirectory and
+ read up on how to install the software.</para>
+ </step>
+
+ <step>
+ <para>If the software was distributed in source format,
+ compile it. This may involve editing a
+ <filename>Makefile</filename> or running a
+ <command>configure</command> script.</para>
+ </step>
+
+ <step>
+ <para>Test and install the software.</para>
+ </step>
+ </procedure>
+
+ <para>A &os; <emphasis>port</emphasis> is a collection of files
+ designed to automate
+ the process of compiling an application from source code. The
+ files that comprise a port contain all the necessary information
+ to automatically download, extract, patch, compile, and install
+ the application.</para>
+
+ <para>If the software has not already been adapted and tested
+ on &os;, the source code might need editing in
+ order for it to install and run properly.</para>
+
+ <para>However, over <link
+ xlink:href="&url.base;/ports/index.html">&os.numports;</link>
+ third-party applications have already been ported to &os;. When
+ feasible, these applications are made available for download as
+ pre-compiled <emphasis>packages</emphasis>.</para>
+
+ <para>Packages
+ can be manipulated with the &os; package management
+ commands.</para>
+
+ <para>Both packages and ports understand dependencies. If a
+ package or port is used to install an application and a
+ dependent library is not already installed, the library will
+ automatically be installed first.</para>
+
+ <para>A &os; package contains pre-compiled copies of all the
+ commands for an application, as well as any configuration files
+ and documentation. A package can be manipulated with the
+ &man.pkg.8; commands, such as
+ <command>pkg install</command>.</para>
+
+ <para>While the two technologies are similar, packages and
+ ports each have their own strengths. Select the technology that
+ meets your requirements for installing a particular
+ application.</para>
+
+ <itemizedlist>
+ <title>Package Benefits</title>
+
+ <listitem>
+ <para>A compressed package tarball is typically smaller than
+ the compressed tarball containing the source code for the
+ application.</para>
+ </listitem>
+
+ <listitem>
+ <para>Packages do not require compilation time. For large
+ applications, such as <application>Mozilla</application>,
+ <application>KDE</application>, or
+ <application>GNOME</application>, this can be important
+ on a slow system.</para>
+ </listitem>
+
+ <listitem>
+ <para>Packages do not require any understanding of the process
+ involved in compiling software on &os;.</para>
+ </listitem>
+ </itemizedlist>
+
+ <itemizedlist>
+ <title>Port Benefits</title>
+
+ <listitem>
+ <para>Packages are normally compiled with conservative
+ options because they have to run on the maximum number of
+ systems. By compiling from the port, one can change the
+ compilation options.</para>
+ </listitem>
+
+ <listitem>
+ <para>Some applications have compile-time options relating to
+ which features are installed. For example,
+ <application>Apache</application> can be configured with a
+ wide variety of different built-in options.</para>
+
+ <para>In some cases, multiple packages will exist for the same
+ application to specify certain settings. For example,
+ <application>Ghostscript</application> is available as a
+ <filename>ghostscript</filename> package and a
+ <filename>ghostscript-nox11</filename> package, depending on
+ whether or not <application>Xorg</application> is installed.
+ Creating multiple packages rapidly becomes impossible if an
+ application has more than one or two different compile-time
+ options.</para>
+ </listitem>
+
+ <listitem>
+ <para>The licensing conditions of some software forbid binary
+ distribution. Such software must be distributed as source
+ code which must be compiled by the end-user.</para>
+ </listitem>
+
+ <listitem>
+ <para>Some people do not trust binary distributions or prefer
+ to read through source code in order to look for potential
+ problems.</para>
+ </listitem>
+
+ <listitem>
+ <para>Source code is needed in
+ order to apply custom patches.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>To keep track of updated ports, subscribe to the
+ &a.ports; and the &a.ports-bugs;.</para>
+
+ <warning>
+ <para>Before installing any application, check <link
+ xlink:href="https://vuxml.freebsd.org/"></link>
+ for security issues related to the application or type
+ <command>pkg audit -F</command> to check all installed
+ applications for known vulnerabilities.</para>
+ </warning>
+
+ <para>The remainder of this chapter explains how to use packages
+ and ports to install and manage third-party software on
+ &os;.</para>
+ </sect1>
+
+ <sect1 xml:id="ports-finding-applications">
+ <title>Finding Software</title>
+
+ <para>&os;'s list of available applications is growing all the
+ time. There are a number of ways to find software to
+ install:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>The &os; web site maintains an up-to-date searchable
+ list of all the available applications, at <link
+ xlink:href="&url.base;/ports/index.html">https://www.FreeBSD.org/ports/</link>.
+ The ports can be searched by application name or by
+ software category.</para>
+ </listitem>
+
+ <listitem>
+ <indexterm><primary>FreshPorts</primary></indexterm>
+
+ <para>Dan Langille maintains <link
+ xlink:href="http://www.FreshPorts.org/">FreshPorts.org</link>
+ which provides a comprehensive search utility and also
+ tracks changes to the applications in the Ports Collection.
+ Registered users can create a customized watch list in order
+ to receive an automated email when their watched ports are
+ updated.</para>
+ </listitem>
+
+ <listitem>
+ <indexterm><primary>SourceForge</primary></indexterm>
+
+ <para>If finding a particular application becomes challenging,
+ try searching a site like <link
+ xlink:href="http://www.sourceforge.net/">SourceForge.net</link>
+ or <link
+ xlink:href="http://www.github.com/">GitHub.com</link> then
+ check back at the <link
+ xlink:href="&url.base;/ports/index.html">&os; site</link>
+ to see if the application has been ported.</para>
+ </listitem>
+
+ <listitem>
+ <indexterm>
+ <primary>pkg</primary>
+ <secondary>search</secondary>
+ </indexterm>
+
+ <para xml:id="pkg-search">To search the binary package
+ repository for an application:</para>
+
+ <screen>&prompt.root; <userinput>pkg search <replaceable>subversion</replaceable></userinput>
+git-subversion-<replaceable>1.9.2</replaceable>
+java-subversion-<replaceable>1.8.8_2</replaceable>
+p5-subversion-<replaceable>1.8.8_2</replaceable>
+py27-hgsubversion-<replaceable>1.6</replaceable>
+py27-subversion-<replaceable>1.8.8_2</replaceable>
+ruby-subversion-<replaceable>1.8.8_2</replaceable>
+subversion-<replaceable>1.8.8_2</replaceable>
+subversion-book-<replaceable>4515</replaceable>
+subversion-static-<replaceable>1.8.8_2</replaceable>
+subversion16-<replaceable>1.6.23_4</replaceable>
+subversion17-<replaceable>1.7.16_2</replaceable></screen>
+
+ <para>Package names include the version number and, in the
+ case of ports based on python, the version number of the
+ version of python the package was built with. Some ports
+ also have multiple versions available. In the case of
+ <application>Subversion</application>, there are different
+ versions available, as well as different compile options.
+ In this case, the statically linked version of
+ <application>Subversion</application>. When indicating
+ which package to install, it is best to specify the
+ application by the port origin, which is the path in the
+ ports tree. Repeat the <command>pkg search</command> with
+ <option>-o</option> to list the origin of each
+ package:</para>
+
+ <screen>&prompt.root; <userinput>pkg search -o <replaceable>subversion</replaceable></userinput>
+devel/git-subversion
+java/java-subversion
+devel/p5-subversion
+devel/py-hgsubversion
+devel/py-subversion
+devel/ruby-subversion
+devel/subversion16
+devel/subversion17
+devel/subversion
+devel/subversion-book
+devel/subversion-static</screen>
+
+ <para>Searching by shell globs, regular expressions, exact
+ match, by description, or any other field in the repository
+ database is also supported by <command>pkg search</command>.
+ After installing <package>ports-mgmt/pkg</package> or
+ <package>ports-mgmt/pkg-devel</package>, see
+ &man.pkg-search.8; for more details.</para>
+ </listitem>
+
+ <listitem>
+ <para>If the Ports Collection is already installed, there are
+ several methods to query the local version of the ports
+ tree. To find out which category a port is in, type
+ <command>whereis <replaceable>file</replaceable></command>,
+ where <replaceable>file</replaceable> is the program to be
+ installed:</para>
+
+ <screen>&prompt.root; <userinput>whereis lsof</userinput>
+lsof: /usr/ports/sysutils/lsof</screen>
+
+ <para>Alternately, an &man.echo.1; statement can be
+ used:</para>
+
+ <screen>&prompt.root; <userinput>echo /usr/ports/*/*lsof*</userinput>
+/usr/ports/sysutils/lsof</screen>
+
+ <para>Note that this will also return any matched files
+ downloaded into the
+ <filename>/usr/ports/distfiles</filename> directory.</para>
+ </listitem>
+
+ <listitem>
+ <para>Another way to find software is by using the Ports
+ Collection's built-in search mechanism. To use the search
+ feature, <application>cd</application> to
+ <filename>/usr/ports</filename> then run <command>make
+ search name=program-name</command> where
+ <replaceable>program-name</replaceable> is the name of the
+ software. For example, to search for
+ <command>lsof</command>:</para>
+
+ <screen>&prompt.root; <userinput>cd /usr/ports</userinput>
+&prompt.root; <userinput>make search name=lsof</userinput>
+Port: lsof-4.88.d,8
+Path: /usr/ports/sysutils/lsof
+Info: Lists information about open files (similar to fstat(1))
+Maint: ler at lerctr.org
+Index: sysutils
+B-deps:
+R-deps: </screen>
+
+ <tip>
+ <para>The built-in search mechanism uses a file
+ of index information. If a message indicates that the
+ <filename>INDEX</filename> is required, run
+ <command>make fetchindex</command> to download the current
+ index file. With the <filename>INDEX</filename> present,
+ <command>make search</command> will be able to perform the
+ requested search.</para>
+ </tip>
+
+ <para>The <quote>Path:</quote> line indicates where to find
+ the port.</para>
+
+ <para>To receive less information, use the
+ <command>quicksearch</command> feature:</para>
+
+ <screen>&prompt.root; <userinput>cd /usr/ports</userinput>
+&prompt.root; <userinput>make quicksearch name=lsof</userinput>
+Port: lsof-4.88.d,8
+Path: /usr/ports/sysutils/lsof
+Info: Lists information about open files (similar to fstat(1))</screen>
+
+ <para>For more in-depth searching, use
+ <command>make search
+ key=<replaceable>string</replaceable></command> or
+ <command>make quicksearch
+ key=<replaceable>string</replaceable></command>, where
+ <replaceable>string</replaceable> is some text to search
+ for. The text can be in comments, descriptions, or
+ dependencies in order to find ports which relate to a
+ particular subject when the name of the program is
+ unknown.</para>
+
+ <para>When using <buildtarget>search</buildtarget> or
+ <buildtarget>quicksearch</buildtarget>, the search string
+ is case-insensitive. Searching for <quote>LSOF</quote> will
+ yield the same results as searching for
+ <quote>lsof</quote>.</para>
+ </listitem>
+ </itemizedlist>
+ </sect1>
+
+ <sect1 xml:id="pkgng-intro">
+ <title>Using <application>pkg</application> for Binary Package
+ Management</title>
+
+ <para><application>pkg</application> is the next generation
+ replacement for the traditional &os; package management tools,
+ offering many features that make dealing with binary packages
+ faster and easier.</para>
+
+ <para>For sites wishing to only use prebuilt binary packages
+ from the &os; mirrors, managing packages with
+ <application>pkg</application> can be sufficient.</para>
+
+ <para>However, for those sites building from source or using their
+ own repositories, a separate <link
+ linkend="ports-upgrading-tools">port management tool</link>
+ will be needed.</para>
+
+ <para>Since <application>pkg</application> only works with
+ binary packages, it
+ is not a replacement for such tools. Those tools can be
+ used to install software from both binary packages
+ and the Ports Collection, while
+ <application>pkg</application> installs only binary
+ packages.</para>
+
+ <sect2 xml:id="pkgng-initial-setup">
+ <title>Getting Started with
+ <application>pkg</application></title>
+
+ <para>&os; includes a bootstrap utility which can be used to
+ download and install <application>pkg</application>
+ and its manual pages. This utility is designed to work
+ with versions of &os; starting with
+ 10.<replaceable>X</replaceable>.</para>
+
+ <note>
+ <para>Not all &os; versions and architectures
+ support this bootstrap process. The current list is at
+ <link xlink:href="https://pkg.freebsd.org/"></link>.
+ For other cases,
+ <application>pkg</application> must instead be installed
+ from the Ports Collection or as a binary package.</para>
+
+ </note>
+
+ <para>To bootstrap the system, run:</para>
+
+ <screen>&prompt.root; <userinput>/usr/sbin/pkg</userinput></screen>
+
+ <para>You must have a working Internet connection for the
+ bootstrap process to succeed.</para>
+
+ <para>Otherwise, to install the port, run:</para>
+
+ <screen>&prompt.root; <userinput>cd /usr/ports/ports-mgmt/pkg</userinput>
+&prompt.root; <userinput>make</userinput>
+&prompt.root; <userinput>make install clean</userinput></screen>
+
+ <para>When upgrading an existing system that originally used the
+ older pkg_* tools, the database must be converted to the
+ new format, so that the new tools are aware of the already
+ installed packages. Once <application>pkg</application> has
+ been installed, the
+ package database must be converted from the traditional format
+ to the new format by running this command:</para>
+
+ <screen>&prompt.root; <userinput>pkg2ng</userinput></screen>
+
+ <note><para>This step is not required for new installations that
+ do not yet have any third-party software
+ installed.</para></note>
+
+ <important>
+ <para>This step is not reversible. Once the package database
+ has been converted to the <application>pkg</application>
+ format, the traditional <literal>pkg_*</literal> tools
+ should no longer be used.</para>
+ </important>
+
+ <note>
+ <para>The package database conversion may emit errors as the
+ contents are converted to the new version. Generally, these
+ errors can be safely ignored. However, a list of
+ software that was not successfully converted
+ is shown after <command>pkg2ng</command> finishes.
+ These applications must be manually reinstalled.</para>
+ </note>
+
+ <para>To ensure that the Ports Collection registers
+ new software with <application>pkg</application> instead of
+ the traditional packages database, &os; versions earlier than
+ 10.<replaceable>X</replaceable> require this line in
+ <filename>/etc/make.conf</filename>:</para>
+
+ <programlisting>WITH_PKGNG= yes</programlisting>
+
+ <para>By default, <application>pkg</application> uses the
+ binary packages from the &os;
+ package mirrors (the <emphasis>repository</emphasis>).
+ For information about building a custom
+ package repository, see
+ <xref linkend="ports-poudriere"/>.</para>
+
+ <para>Additional <application>pkg</application> configuration
+ options are described in &man.pkg.conf.5;.</para>
+
+ <para>Usage information for <application>pkg</application> is
+ available in the &man.pkg.8; manual page or by running
+ <command>pkg</command> without additional arguments.</para>
+
+ <para>Each <application>pkg</application> command argument is
+ documented in a command-specific manual page. To read the
+ manual page for <command>pkg install</command>, for example,
+ run either of these commands:</para>
+
+ <screen>&prompt.root; <userinput>pkg help install</userinput></screen>
+
+ <screen>&prompt.root; <userinput>man pkg-install</userinput></screen>
+
+ <para>The rest of this section demonstrates common binary
+ package management tasks which can be performed using
+ <application>pkg</application>. Each demonstrated command
+ provides many switches to customize its use. Refer to a
+ command's help or man page for details and more
+ examples.</para>
+ </sect2>
+
+ <sect2 xml:id="quarterly-latest-branch">
+ <title>Quarterly and Latest Ports Branches</title>
+
+ <para>The <literal>Quarterly</literal> branch provides users
+ with a more predictable and stable experience for port and
+ package installation and upgrades. This is done essentially
+ by only allowing non-feature updates. Quarterly branches aim
+ to receive security fixes (that may be version updates, or
+ backports of commits), bug fixes and ports compliance or
+ framework changes. The Quarterly branch is cut from HEAD at
+ the beginning of every (yearly) quarter in January, April,
+ July, and October. Branches are named according to the year
+ (YYYY) and quarter (Q1-4) they are created in. For example,
+ the quarterly branch created in January 2016, is named 2016Q1.
+ And the <literal>Latest</literal> branch provides the latest
+ versions of the packages to the users.</para>
+
+ <para>To switch from quarterly to latest run the following
+ commands:</para>
+
+ <screen>&prompt.root; <userinput>cp /etc/pkg/FreeBSD.conf /usr/local/etc/pkg/repos/FreeBSD.conf</userinput></screen>
+
+ <para>Edit the file
+ <filename>/usr/local/etc/pkg/repos/FreeBSD.conf</filename>
+ and change the string <emphasis>quarterly</emphasis> to
+ <emphasis>latest</emphasis> in the <literal>url:</literal>
+ line.</para>
+
+ <para>The result should be similar to the following:</para>
+
+ <programlisting>FreeBSD: {
+ url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
+ mirror_type: "srv",
+ signature_type: "fingerprints",
+ fingerprints: "/usr/share/keys/pkg",
+ enabled: yes
+}</programlisting>
+
+ <para>And finally run this command to update from the new
+ (latest) repository metadata.</para>
+
+ <screen>&prompt.root; <userinput>pkg update -f</userinput></screen>
+
+ </sect2>
+
+ <sect2 xml:id="pkgng-pkg-info">
+ <title>Obtaining Information About Installed Packages</title>
+
+ <para>Information about the packages installed on a system
+ can be viewed by running <command>pkg info</command> which,
+ when run without any switches, will list the package version
+ for either all installed packages or the specified
+ package.</para>
+
+ <para>For example, to see which version of
+ <application>pkg</application> is installed, run:</para>
+
+ <screen>&prompt.root; <userinput>pkg info pkg</userinput>
+pkg-1.1.4_1</screen>
+ </sect2>
+
+ <sect2 xml:id="pkgng-installing-deinstalling">
+ <title>Installing and Removing Packages</title>
+
+ <para>To install a binary package use the following command,
+ where <replaceable>packagename</replaceable> is the name of
+ the package to install:</para>
+
+ <screen>&prompt.root; <userinput>pkg install <replaceable>packagename</replaceable></userinput></screen>
+
+ <para>This command uses repository data to determine which
+ version of the software to install and if it has any
+ uninstalled dependencies. For example, to install
+ <application>curl</application>:</para>
+
+ <screen>&prompt.root; <userinput>pkg install curl</userinput>
+Updating repository catalogue
+/usr/local/tmp/All/curl-7.31.0_1.txz 100% of 1181 kB 1380 kBps 00m01s
+
+/usr/local/tmp/All/ca_root_nss-3.15.1_1.txz 100% of 288 kB 1700 kBps 00m00s
+
+Updating repository catalogue
+The following 2 packages will be installed:
+
+ Installing ca_root_nss: 3.15.1_1
+ Installing curl: 7.31.0_1
+
+The installation will require 3 MB more space
+
+0 B to be downloaded
+
+Proceed with installing packages [y/N]: <userinput>y</userinput>
+Checking integrity... done
+[1/2] Installing ca_root_nss-3.15.1_1... done
+[2/2] Installing curl-7.31.0_1... done
+Cleaning up cache files...Done</screen>
+
+ <para>The new package and any additional packages that were
+ installed as dependencies can be seen in the installed
+ packages list:</para>
+
+ <screen>&prompt.root; <userinput>pkg info</userinput>
+ca_root_nss-3.15.1_1 The root certificate bundle from the Mozilla Project
+curl-7.31.0_1 Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers
+pkg-1.1.4_6 New generation package manager</screen>
+
+ <para>Packages that are no longer needed can be removed with
+ <command>pkg delete</command>. For example:</para>
+
+ <screen>&prompt.root; <userinput>pkg delete curl</userinput>
+The following packages will be deleted:
+
+ curl-7.31.0_1
+
+The deletion will free 3 MB
+
+Proceed with deleting packages [y/N]: <userinput>y</userinput>
+[1/1] Deleting curl-7.31.0_1... done</screen>
+ </sect2>
+
+ <sect2 xml:id="pkgng-upgrading">
+ <title>Upgrading Installed Packages</title>
+
+ <para>Installed packages can be upgraded to their latest
+ versions by running:</para>
+
+ <screen>&prompt.root; <userinput>pkg upgrade</userinput></screen>
+
+ <para>This command will compare the installed versions with
+ those available in the repository catalogue and upgrade them
+ from the repository.</para>
+ </sect2>
+
+ <sect2 xml:id="pkgng-auditing">
+ <title>Auditing Installed Packages</title>
+
+ <para>Software vulnerabilities are regularly discovered
+ in third-party applications. To address this,
+ <application>pkg</application> includes a built-in auditing
+ mechanism. To determine if there are any known
+ vulnerabilities for the software installed on the system,
+ run:</para>
+
+ <screen>&prompt.root; <userinput>pkg audit -F</userinput></screen>
+ </sect2>
+
+ <sect2 xml:id="pkgng-autoremove">
+ <title>Automatically Removing Unused Packages</title>
+
+ <para>Removing a package may leave behind dependencies which
+ are no longer required. Unneeded packages that were installed
+ as dependencies (leaf packages) can be automatically detected
+ and removed using:</para>
+
+ <screen>&prompt.root; <userinput>pkg autoremove</userinput>
+Packages to be autoremoved:
+ ca_root_nss-3.15.1_1
+
+The autoremoval will free 723 kB
+
+Proceed with autoremoval of packages [y/N]: <userinput>y</userinput>
+Deinstalling ca_root_nss-3.15.1_1... done</screen>
+
+ <para>Packages installed as dependencies are
+ called <emphasis>automatic</emphasis> packages. Non-automatic
+ packages, i.e the packages that were explicity installed not
+ as a dependency to another package, can be listed
+ using:</para>
+
+ <screen>&prompt.root; <userinput>pkg prime-list</userinput>
+nginx
+openvpn
+sudo</screen>
+
+ <para><command>pkg prime-list</command> is an alias command
+ declared in <filename>/usr/local/etc/pkg.conf</filename>.
+ There are many others that can be used to query the package
+ database of the system. For instance, command
+ <command>pkg prime-origins</command> can be used to get the
+ origin port directory of the list mentioned above:</para>
+
+ <screen>&prompt.root; <userinput>pkg prime-origins</userinput>
+www/nginx
+security/openvpn
+security/sudo</screen>
+
+ <para>This list can be used to rebuild all packages
+ installed on a system using build tools such as <package>
+ ports-mgmt/poudriere</package> or <package>
+ ports-mgmt/synth</package>.</para>
+
+ <para>Marking an installed package as automatic can be
+ done using:</para>
+
+ <screen>&prompt.root; <userinput>pkg set -A 1 devel/cmake</userinput></screen>
+
+ <para>Once a package is a leaf package and is marked
+ as automatic, it gets selected by
+ <command>pkg autoremove</command>.</para>
+
+ <para>Marking an installed package as <emphasis>not</emphasis>
+ automatic can be done using:</para>
+
+ <screen>&prompt.root; <userinput>pkg set -A 0 devel/cmake</userinput></screen>
+
+ </sect2>
+
+ <sect2 xml:id="pkgng-backup">
+ <title>Restoring the Package Database</title>
+
+ <para>Unlike the traditional package management system,
+ <application>pkg</application> includes its own package
+ database backup mechanism. This functionality is enabled by
+ default.</para>
+
+ <tip>
+ <para>To disable the periodic script from backing up the
+ package database, set
+ <literal>daily_backup_pkgdb_enable="NO"</literal> in
+ &man.periodic.conf.5;.</para>
+ </tip>
+
+ <para>To restore the contents of a previous package database
+ backup, run the following command replacing
+ <replaceable>/path/to/pkg.sql</replaceable> with the location
+ of the backup:</para>
+
+ <screen>&prompt.root; <userinput>pkg backup -r <replaceable>/path/to/pkg.sql</replaceable></userinput></screen>
+
+ <note>
+ <para>If restoring a backup taken by the periodic script,
+ it must be decompressed prior to being restored.</para>
+ </note>
+
+ <para>To run a manual backup of the
+ <application>pkg</application> database, run the following
+ command, replacing <replaceable>/path/to/pkg.sql</replaceable>
+ with a suitable file name and location:</para>
+
+ <screen>&prompt.root; <userinput>pkg backup -d <replaceable>/path/to/pkg.sql</replaceable></userinput></screen>
+ </sect2>
+
+ <sect2 xml:id="pkgng-clean">
+ <title>Removing Stale Packages</title>
+
+ <para>By default, <application>pkg</application> stores
+ binary packages in a cache directory defined by
+ <envar>PKG_CACHEDIR</envar> in &man.pkg.conf.5;. Only copies
+ of the latest installed packages are kept. Older versions of
+ <application>pkg</application> kept all previous packages. To
+ remove these outdated binary packages, run:</para>
+
+ <screen>&prompt.root; <userinput>pkg clean</userinput></screen>
+
+ <para>The entire cache may be cleared by running:</para>
+
+ <screen>&prompt.root; <userinput>pkg clean -a</userinput></screen>
+ </sect2>
+
+ <sect2 xml:id="pkgng-set">
+ <title>Modifying Package Metadata</title>
+
+ <para>Software within the &os; Ports Collection can
+ undergo major version number changes. To address this,
+ <application>pkg</application> has a built-in command to
+ update package origins. This can be useful, for example, if
+ <package>lang/php5</package> is renamed to
+ <package>lang/php53</package> so that
+ <package>lang/php5</package> can now
+ represent version <literal>5.4</literal>.</para>
+
+ <para>To change the package origin for the above example,
+ run:</para>
+
+ <screen>&prompt.root; <userinput>pkg set -o lang/php5:lang/php53</userinput></screen>
+
+ <para>As another example, to update
+ <package>lang/ruby18</package> to
+ <package>lang/ruby19</package>, run:</para>
+
+ <screen>&prompt.root; <userinput>pkg set -o lang/ruby18:lang/ruby19</userinput></screen>
+
+ <para>As a final example, to change the origin of the
+ <filename>libglut</filename> shared libraries from
+ <package>graphics/libglut</package> to
+ <package>graphics/freeglut</package>, run:</para>
+
+ <screen>&prompt.root; <userinput>pkg set -o graphics/libglut:graphics/freeglut</userinput></screen>
+
+ <note>
+ <para>When changing package origins, it is important to
+ reinstall packages that are dependent on the package with
+ the modified origin. To force a reinstallation of dependent
+ packages, run:</para>
+
+ <screen>&prompt.root; <userinput>pkg install -Rf <replaceable>graphics/freeglut</replaceable></userinput></screen>
+ </note>
+ </sect2>
+ </sect1>
+
+ <sect1 xml:id="ports-using">
+ <title>Using the Ports Collection</title>
+
+ <para>The Ports Collection is a set of
+ <filename>Makefile</filename>s, patches, and description files.
+ Each set of these files is used to compile and install an
+ individual application on &os;, and is called a
+ <emphasis>port</emphasis>.</para>
+
+ <para>By default, the Ports Collection itself is stored as a
+ subdirectory of <filename>/usr/ports</filename>.</para>
+
+ <para>Before an application can be compiled using a port, the
+ Ports Collection must first be installed. If it was not
+ installed during the installation of &os;, use one of the
+ following methods to install it:</para>
+
+ <procedure xml:id="ports-using-portsnap-method">
+ <title>Portsnap Method</title>
+
+ <para>The base system of &os; includes
+ <application>Portsnap</application>. This is a fast and
+ user-friendly tool for retrieving the Ports Collection and
+ is the recommended choice for most users not running
+ &os.current;. This utility
+ connects to a &os; site, verifies the secure key, and
+ downloads a new copy of the Ports Collection. The key is used
+ to verify the integrity of all downloaded files.</para>
+
+ <step>
+ <para>To download a compressed snapshot of the Ports
+ Collection into
+ <filename>/var/db/portsnap</filename>:</para>
+
+ <screen>&prompt.root; <userinput>portsnap fetch</userinput></screen>
+ </step>
+
+ <step>
+ <para>When running <application>Portsnap</application> for the
+ first time, extract the snapshot into
+ <filename>/usr/ports</filename>:</para>
+
+ <screen>&prompt.root; <userinput>portsnap extract</userinput></screen>
+ </step>
+
+ <step>
+ <para>After the first use of
+ <application>Portsnap</application> has been completed as
+ shown above, <filename>/usr/ports</filename> can be updated
+ as needed by running:</para>
+
+ <screen>&prompt.root; <userinput>portsnap fetch</userinput>
+&prompt.root; <userinput>portsnap update</userinput></screen>
+
+ <para>When using <literal>fetch</literal>, the
+ <literal>extract</literal> or the <literal>update</literal>
+ operation may be run consecutively, like so:</para>
+
+ <screen>&prompt.root; <userinput>portsnap fetch update</userinput></screen>
+ </step>
+ </procedure>
+
+ <procedure xml:id="ports-using-subversion-method">
+ <title>Subversion Method</title>
+
+ <para>If more control over the ports tree is needed or if local
+ changes need to be maintained, or if running &os.current;,
+ <application>Subversion</application> can be used to obtain
+ the Ports Collection. Refer to <link
+ xlink:href="&url.articles.committers-guide;/subversion-primer.html">the
+ Subversion Primer</link> for a detailed description of
+ <application>Subversion</application>.</para>
+
+ <step>
+ <para><application>Subversion</application> must be installed
+ before it can be used to check out the ports tree. If a
+ copy of the ports tree is already present, install
+ <application>Subversion</application> like this:</para>
+
+ <screen>&prompt.root; <userinput>cd /usr/ports/devel/subversion</userinput>
+&prompt.root; <userinput>make install clean</userinput></screen>
+
+ <para>If the ports tree is not available, or
+ <application>pkg</application> is being used to manage
+ packages, <application>Subversion</application> can be
+ installed as a package:</para>
+
+ <screen>&prompt.root; <userinput>pkg install subversion</userinput></screen>
+
+ </step>
+
+ <step>
+ <para>Check out a copy of the ports tree:</para>
+
+ <screen>&prompt.root; <userinput>svn checkout https://svn.FreeBSD.org/ports/head /usr/ports</userinput></screen>
+ </step>
+
+ <step>
+ <para>As needed, update <filename>/usr/ports</filename> after
+ the initial <application>Subversion</application>
+ checkout:</para>
+
+ <screen>&prompt.root; <userinput>svn update /usr/ports</userinput></screen>
+ </step>
+ </procedure>
+
+ <para>The Ports Collection contains directories
+ for software categories. Inside each category are
+ subdirectories for individual applications. Each application
+ subdirectory contains a set of files that
+ tells &os; how to compile and install that program,
+ called a <emphasis>ports skeleton</emphasis>. Each port
+ skeleton includes these files and directories:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para><filename>Makefile</filename>: contains statements that
+ specify how the application should be compiled and where
+ its components should be installed.</para>
+ </listitem>
+
+ <listitem>
+ <para><filename>distinfo</filename>: contains the names and
+ checksums of the files that must be downloaded to build the
+ port.</para>
+ </listitem>
+
+ <listitem>
+ <para><filename>files/</filename>: this directory contains
+ any patches needed for the program to compile and install
+ on &os;. This directory may also contain other files used
+ to build the port.</para>
+ </listitem>
+
+ <listitem>
+ <para><filename>pkg-descr</filename>: provides a more detailed
+ description of the program.</para>
+ </listitem>
*** 892 LINES SKIPPED ***
More information about the dev-commits-doc-all
mailing list