FreeBSD. Ports, Packages, and Software Updates

FreeBSD comes with a rich set of system utilities as part of its base system. However, the need to install additional applications from third-party developers arises very soon.
FreeBSD provides two complementary technologies for installing third-party software on your system:
- The FreeBSD Ports Collection
- Binary software packages
Either of these systems can be used to install the latest versions of your favorite applications from local media or directly from the network.
The article BSD vs Linux. What Is a “Port”? will help answer the question “What are ports and packages?” Here, we’ll talk about how to work with this whole system.
Packages
Installing a package
pkg_add -r название_пакета
where “-r” means “remote”, i.e., it will be downloaded from the Internet.
List of installed packages
pkg_info
or information about a package
pkg_info название_пакета
Removing a package
pkg_delete название_пакета
Package version
pkg_version название_пакета
Finding Software
To check whether a piece of software is installed, you can use:
whereis название_пакета
(which/locate/find) and
pkg_info | grep название_пакета
I also recommend www.freshports.org for finding packages and ports!
Ports
Installation
make install
make install clean
Installation with automatic acceptance of the default configurations for ports:
make -DBATCH install clean
Reinstallation
make reinstall
Removal
make deinstall
Cleaning up intermediate build files
make clean
Cleaning up downloaded files
make distclean
Pre-installation configuration (otherwise, installation will use the configuration saved during the previous build)
make config
Finding a port by keyword
make search key=КЛЮЧ
Finding a port by name
make search name=ИМЯ
Show a list of a port’s dependencies
make all-depends-list
Example,
cd /usr/ports/www/apache22/
make config
make install clean
These are the basic commands; more details are available on the official FreeBSD Handbook page. Or see the file /usr/ports/Mk/bsd.port.mk
After Installing Software
I recommend running “rehash” so that you can use “program” directly instead of typing the full path “/path/to/program”:
# rehash
Updating the Ports Tree
The portsnap utility has been included in the base distribution since FreeBSD 6.0; for earlier versions, it needs to be installed (/usr/ports/sysutils/portsnap/).
For the first update, run the following commands:
portsnap fetch && portsnap extract
For subsequent updates
portsnap fetch update
Example,
cd /usr/ports/
portsnap fetch && portsnap extract
More details here.
Updating a Port
The portupgrade utility must be installed first!
cd /usr/ports/sysutils/portupgrade/
make install clean
Updating
portupgrade название_программы
If you want to update only a specific application rather than the entire database, use portupgrade pkgname, with the -r flag if portupgrade should process all packages that depend on the specified package, and use the -R flag to process all packages that the specified packages require.
To install a port (while fixing dependency problems, etc.), run it with the “-N” flag:
portupgrade -N название_программы
More details about portupgrade here and here.
P.S. I use the ports system, and I recommend that you do too.
Comments are closed. Read the original discussion in Russian →