The remainder of this chapter explains how to use packages and ports to install and manage third-party software on FreeBSD.
There are a number of ways to find software to install:. The ports can be searched by application name or by software category. Dan Langille maintains FreshPorts.
Registered users can create a customized watch list in order to receive an automated email when their watched ports are updated. If finding a particular application becomes challenging, try searching a site like SourceForge. 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 Subversion, there are different versions available, as well as different compile options. In this case, the statically linked version of Subversion. 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 pkg search with -o to list the origin of each package:.
Searching by shell globs, regular expressions, exact match, by description, or any other field in the repository database is also supported by pkg search. 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 whereis file , where file is the program to be installed:.
Alternately, an echo 1 statement can be used:. For example, to search for lsof :. The built-in search mechanism uses a file of index information.
If a message indicates that the INDEX is required, run make fetchindex to download the current index file.
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. When using search or quicksearch , the search string is case-insensitive. Searching for "LSOF" will yield the same results as searching for "lsof". For sites wishing to only use prebuilt binary packages from the FreeBSD mirrors, managing packages with pkg can be sufficient.
However, for those sites building from source or using their own repositories, a separate port management tool will be needed. Since pkg 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 pkg installs only binary packages.
FreeBSD includes a bootstrap utility which can be used to download and install pkg and its manual pages. This utility is designed to work with versions of FreeBSD starting with Not all FreeBSD versions and architectures support this bootstrap process. For other cases, pkg must instead be installed from the Ports Collection or as a binary package.
Once pkg has been installed, the package database must be converted from the traditional format to the new format by running this command:. This step is not required for new installations that do not yet have any third-party software installed. This step is not reversible. 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 pkg2ng finishes.
These applications must be manually reinstalled. To ensure that the Ports Collection registers new software with pkg instead of the traditional packages database, FreeBSD versions earlier than By default, pkg uses the binary packages from the FreeBSD package mirrors the repository.
For information about building a custom package repository, see Building Packages with Poudriere. Additional pkg configuration options are described in pkg. Usage information for pkg is available in the pkg 8 manual page or by running pkg without additional arguments. Each pkg command argument is documented in a command-specific manual page. To read the manual page for pkg install , for example, run either of these commands:. The rest of this section demonstrates common binary package management tasks which can be performed using pkg.
Each demonstrated command provides many switches to customize its use. The Quarterly 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. For example, the quarterly branch created in January , is named Q1.
And the Latest branch provides the latest versions of the packages to the users. Information about the packages installed on a system can be viewed by running pkg info which, when run without any switches, will list the package version for either all installed packages or the specified package. To install a binary package use the following command, where packagename is the name of the package to install:. 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 curl:. The new package and any additional packages that were installed as dependencies can be seen in the installed packages list:. This command will compare the installed versions with those available in the repository catalogue and upgrade them from the repository.
Software vulnerabilities are regularly discovered in third-party applications. To address this, pkg includes a built-in auditing mechanism. To determine if there are any known vulnerabilities for the software installed on the system, run:.
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:. Packages installed as dependencies are called automatic packages. Non-automatic packages, i.
There are many others that can be used to query the package database of the system. For instance, command pkg prime-origins can be used to get the origin port directory of the list mentioned above:. Once a package is a leaf package and is marked as automatic, it gets selected by pkg autoremove. Unlike the traditional package management system, pkg includes its own package database backup mechanism.
This functionality is enabled by default. If restoring a backup taken by the periodic script, it must be decompressed prior to being restored.
Only copies of the latest installed packages are kept. Older versions of pkg kept all previous packages. To remove these outdated binary packages, run:. To address this, pkg has a built-in command to update package origins. 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:. The Ports Collection is a set of Makefile s, patches, and description files. Each set of these files is used to compile and install an individual application on FreeBSD, and is called a port. Using pkg for Binary Package Management chapter. Before FreeBSD Currently only the only supported releases of FreeBSD are recently released If for some reason you will find that pkg 8 tools does not work or are broken you may connect to it with sqlite3 command from the sqlite3 package.
Do not use the sqlite package as it holds the 2. With pkg 8 specified packages can now be locked with pkg lock command. This means that the pkg upgrade or even pkg delete operations or pkg autoremove would not touch them.
You can list locked packages with -l options as shown below. As you can see its not possible to pkg delete the locked exfat-utils package.
You will first have to unlock it with pkg unlock command. You can do that interactively or not with -y option as shown below. I combine ports and packages practice often discouraged in the FreeBSD world because some software I use is not available as packages — because of licensing issues. I also need to build custom version of ffmpeg package — just to include lame support but still custom.
The last thing I keep locked is Conky. It was and still is working great in 1. It was just not possible to right click with mouse on the desktop and have Openbox menu — or to name the issue — Conky did not pass mouse events to the Window Manager that ruled the desktop. So I used one of the other Ports tools, the portdowngrade to fetch last 1. Why it is so useful? The pkg-provides plugin allows you to query which package provides a particular file directly with pkg 8 tool.
It is even available as pkg-provides package. Below I will show you how to install and configure it. First install the pkg-provides package. Next time you will type the pkg upgrade command you would also see provides database updating. While the pkg provides needed information for the files of packages that are not yet installed the pkg which command is the pkg 8 equivalent of the classic UNIX which command.
It shows to which package a file belongs to or not at all. In most every case there will be instructions for how to use portmaster to perform the task. The remaining ports can be updated using the following command:. After entering the command above portmaster will recurse through the port and its dependencies if any to handle any configuration options.
If configuration options have changed since the last time the port was updated, portmaster will likely prompt for input. However, you can force the configuration dialogs for all ports by adding the force-config option to the command:. You can skip the confirmation step by adding the no-confirm option to the command:. The -a options tells portmaster to review all installed ports and update them if necessary.
Reported by: lev Approved by: antoine implicit. Fix version number I have to remember to manually fix-up this string before each commit and I'll whether I can create a pre-commit script that checks this for me. Remove spurious trace output left over from debugging. I'm not sure, that this is a useful feature, and the txz-format is currently hard-wired in a lot of places in portmaster, but there has been a request to allow creation of packages in a non-standard archive format.
Fix package name: the pattern that gets replaced with the actual version string at build time had been replaced by a version string from a test version. Reported by: herbert gojira. Skuhra Approved by: antoine implicit. Support for different archive format for packages in general could be provided, but not added at this time, since I'm not convinced that this would be a useful feature please let me know, if you disagree Fix installation from local or remote package including the --packages-build case.
Partially based on patches supplied by Alexander Leidinger. Reported by: phk, netchild Approved by: antoine implicit. Reported by: phk Approved by: antoine implicit. The port used to patch the man-page, but then installed the unpatched version. Fix execution of portmaster in a port directory without any port or package parameters. Reported by: lenzi. Add flavor support to routines that convert port origins to shell variable names.
The patch attached to PR did no longer apply cleanly, therefore I edited portmaster to follow the intent and in part the letter of the patch. This patch should not affect port building in any way. I have no use for the feature and I'm still considering to completely remove support for the installation of packages in portmaster , and therefore did not test that it performs as expected by the submitter.
PR: Submitted by: rozhuk. Add all-depends-list case required for portmaster -t. Remove stray double-quote character left from an incomplete edit of that line result of directly editing the patch for a trivial change Add support for ports that have been upgraded with a change of both origin and package name sans version , as was the case for e.
Fix query for package to be replaced: This could lead to a wrong package being identified and replaced when the new package is installed. Add library dependencies to the list of build dependencies to consider. Reported by: Robert Huff Approved by: antoine implicit. USe correct origin in multiport case several packages specified on the command line, which is different from passing "-a". Add another check for a flavor passed attached to the port directory. Without this fix, the default flavor was built in specific situations.
Fix patch: The patch had been created from the version used to debug the previous version's problem and I forgot to Fix shbang: Remove the -x that had been added for debugging. Reported by: Walter Schwarzenfeld w. Move its definition to an appropriate place. Silence one pkq query command that may be called for a non-existing package name. Add flavor support to portmaster. This version has been lightly tested and supports upgrades from non-flavored port versions based on the information in the MOVED file.
For initial installations of flavored ports, the flavor must be specified as part of the port origin, e. Dependent ports will automatically be installed with the correct flavor passed via the dependency mechanism.
0コメント