How to Use Ports Collection on FreeBSD?
FreeBSD is a prominent server platform and free, open-source Unix-like operating system. FreeBSD is an operating system designed to operate on contemporary servers, personal computers, and embedded devices. The FreeBSD Ports and Packages Collection provides users and administrators with an easy method for installing programs.
The Ports Collection is compatible with the most recent FreeBSD-CURRENT and FreeBSD-STABLE releases. Older versions are not supported and may or may not function successfully with a current set of ports. Eventually, modifications to the ports collection may depend on the functionality that was absent from earlier editions.
In this article we will cover the following topics:
- What is Ports Collection?
- How to Install Ports Collection?
- How to Install Ports Collection with Git Method?
- How to Install Ports Collection with Portsnap Method?
- How to Install Ports?
- How to Customize Ports Installation?
- How to Remove Installed Ports?
- How to View Installed Ports?
- How to Upgrade Ports?
- How to Upgrade Ports with Portmaster?
- How to Upgrade Ports with portupgrade ?
- How to Manage Disk Size With Ports?
- How to Build Packages with Poudriere?
- How to Initialize Jails and Port Trees?
- How to Configure pkg Clients to Integrate with a Poudriere Repository?
- What are the Post Installation Considerations?
What is Ports Collection?
Makefiles, patches, and description files constitute the Ports Collection. Each collection of these files needed to create and install a unique application under FreeBSD is known as a port.
The Ports Collection is kept under a subfolder of /usr/ports
by default.
The Ports Collection comprises software category directories. Within each category are distinct application subdirectories. Each application subdirectory has a collection of files called a ports skeleton that instructs FreeBSD on how to develop and install that program. Each port template has the following files and directories:
-
Makefile: specifies how a program is to be built and where its components are to be installed.
-
distinfo: includes the names and checksums of the files required for building the port.
-
pkg-plist: A list of all files that will be installed by the port. Additionally, it instructs the ports system which files to delete upon uninstallation.
-
pkg-descr: offers a more comprehensive description of the package.
-
files/: This directory includes any fixes required to build and install the software on FreeBSD. This directory may include other port-building files.
Some ports contain pkg-message and/or other files to handle unusual circumstances.
The port does not include the source code itself, often known as a distfile
. The /usr/ports/distfiles
directory is automatically populated with the downloaded source code during the extract phase of port development.
Before installing and using the Ports Collection, please be aware that it is typically not recommended to install applications using the Ports Collection in combination with binary packages offered by pkg
. pkg
follows quarterly branch-releases of the ports tree by default and not HEAD. There may be conflicts between dependencies installed by pkg
and those from the Ports Collection if the dependencies for a port in HEAD vary from its equivalent in a quarterly branch release. Ensure that the Ports Collection and pkg
are on the same branch release of the ports tree if they must be used together.
How to Install Ports Collection?
Prior to compiling an application requiring a port, the Ports Collection must be installed. If it was not installed during the FreeBSD installation process, you may install Ports Collection using one of the following methods:
-
Git
-
Portsnap
How to Install Ports Collection with Git Method?
Git may be used to retrieve the Ports Collection if additional control over the ports tree is required, if local modifications need to be kept, or if you are using FreeBSD-CURRENT. You may follow the steps below to install Ports Collection using Git:
-
Git must be installed by running the following commands before the ports tree can be checked out. If an existing copy of the ports tree is available, install Git as follows:
cd /usr/ports/devel/git
make clean installGit may be installed as a package by running the next command if the ports tree is unavailable or if pkg is used to manage packages.
pkg install git
You should see the output similar to the given below:
Updating FreeBSD repository catalogue...
Fetching packagesite.pkg: 100% 6 MiB 2.3MB/s 00:03
Processing entries: 100%
FreeBSD repository update completed. 32622 packages processed.
All repositories are up to date.
The following 28 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
ca_root_nss: 3.85 [FreeBSD]
curl: 7.85.0 [FreeBSD]
git: 2.38.1_4 [FreeBSD]
libidn2: 2.3.3_1 [FreeBSD]
libnghttp2: 1.48.0 [FreeBSD]
........................
p5-HTTP-Message: 6.39 [FreeBSD]
p5-IO-HTML: 1.004 [FreeBSD]
p5-IO-Socket-INET6: 2.72_1 [FreeBSD]
p5-IO-Socket-SSL: 2.077 [FreeBSD]
p5-LWP-MediaTypes: 6.04 [FreeBSD]
p5-Mozilla-CA: 20221114 [FreeBSD]
p5-Net-SSLeay: 1.92 [FreeBSD]
p5-Socket6: 0.29 [FreeBSD]
p5-TimeDate: 2.33,1 [FreeBSD]
p5-URI: 5.15 [FreeBSD]
Number of packages to be installed: 28
The process will require 47 MiB more space.
6 MiB to be downloaded.
Proceed with this action? [y/N]: y
[1/15] Fetching p5-CGI-4.54.pkg: 100% 155 KiB 158.6kB/s 00:01
[2/15] Fetching p5-TimeDate-2.33,1.pkg: 100% 33 KiB 33.5kB/s 00:01
[3/15] Fetching p5-Clone-0.45.pkg: 100% 10 KiB 10.5kB/s 00:01
[4/15] Fetching p5-Error-0.17029.pkg: 100% 27 KiB 27.3kB/s 00:01
[5/15] Fetching p5-HTML-Tagset-3.20_1.pkg: 100% 12 KiB 12.0kB/s 00:01
[6/15] Fetching git-2.38.1_4.pkg: 100% 6 MiB 2.0MB/s 00:03
[7/15] Fetching p5-Authen-SASL-2.16_1.pkg: 100% 40 KiB 41.5kB/s 00:01
[8/15] Fetching p5-Socket6-0.29.pkg: 100% 17 KiB 17.4kB/s 00:01
[9/15] Fetching p5-HTTP-Date-6.05.pkg: 100% 10 KiB 10.6kB/s 00:01
[10/15] Fetching p5-GSSAPI-0.28_2.pkg: 100% 39 KiB 40.4kB/s 00:01
[11/15] Fetching p5-IO-Socket-INET6-2.72_1.pkg: 100% 13 KiB 13.1kB/s 00:01
[12/15] Fetching p5-Encode-Locale-1.05.pkg: 100% 12 KiB 11.9kB/s 00:01
[13/15] Fetching p5-LWP-MediaTypes-6.04.pkg: 100% 20 KiB 20.1kB/s 00:01
[14/15] Fetching p5-IO-HTML-1.004.pkg: 100% 15 KiB 15.4kB/s 00:01
[15/15] Fetching p5-Digest-HMAC-1.04.pkg: 100% 14 KiB 14.1kB/s 00:01
Checking integrity... done (0 conflicting)
[1/28] Installing p5-TimeDate-2.33,1...
[1/28] Extracting p5-TimeDate-2.33,1: 100%
[2/28] Installing p5-URI-5.15...
[2/28] Extracting p5-URI-5.15: 100%
[3/28] Installing libunistring-1.1...
[3/28] Extracting libunistring-1.1: 100%
...........
All you have to do to make gitweb work is:
1) Please be sure you're able to execute CGI scripts in
/usr/local/share/examples/git/gitweb.
2) Set the GITWEB_CONFIG variable in your webserver's config to
/usr/local/etc/git/gitweb.conf. This variable is passed to gitweb.cgi.
3) Restart server.
If you installed the CONTRIB option please note that the scripts are installed in /usr/local/share/git-core/contrib. Some of them require other ports to be installed (perl, python, etc), which you may need to install manually.
pkg install git 6.25s user 1.53s system 18% cpu 42.495 total -
You may run the next command to check out a copy of the ports tree's HEAD branch:
git clone https://git.FreeBSD.org/ports.git /usr/ports
Cloning into '/usr/ports'...
remote: Enumerating objects: 5663197, done.
remote: Counting objects: 100% (973/973), done.
remote: Compressing objects: 100% (157/157), done.
remote: Total 5663197 (delta 931), reused 816 (delta 816), pack-reused 5662224
Receiving objects: 100% (5663197/5663197), 1.01 GiB | 2.88 MiB/s, done.
Resolving deltas: 100% (3416262/3416262), done.
Updating files: 100% (150570/150570), done.
git clone https://git.FreeBSD.org/ports.git /usr/ports 539.81s user 124.34s system 97% cpu 11:24.47 totalOr, to check out a copy of a quarterly branch run the following command:
git clone https://git.FreeBSD.org/ports.git /usr/ports -b 2022Q4
You should see the output similar to the given below:
Cloning into '/usr/ports'...
remote: Enumerating objects: 5663197, done.
remote: Counting objects: 100% (936/936), done.
remote: Compressing objects: 100% (120/120), done.
remote: Total 5663197 (delta 923), reused 816 (delta 816), pack-reused 5662261
Receiving objects: 100% (5663197/5663197), 1.01 GiB | 2.88 MiB/s, done.
Resolving deltas: 100% (3416275/3416275), done.
Updating files: 100% (147690/147690), done.
git clone https://git.FreeBSD.org/ports.git /usr/ports -b 2022Q4 527.47s user 125.50s system 96% cpu 11:15.12 total -
Update
/usr/ports
as necessary after the first Git checkout by running the next command:git -C /usr/ports pull
-
You may change
/usr/ports
to a different quarterly branch if required by running the following commands:git -C switch /usr/ports 2022Q4
How to Install Ports Collection with Portsnap Method?
FreeBSD's base system features Portsnap. This is the preferred method for getting the Ports Collection, since it is quick and straightforward. This tool establishes a connection with a FreeBSD server, validates the secure key, and downloads a fresh copy of the Ports Collection. All downloaded files' integrity is verified using the key. You may follow the steps below to install Ports Collection using portsnap:
-
To download a compressed snapshot of the Ports Collection to
/var/db/portsnap
, use the following command:portsnap fetch
You should see the output similar to the given below:
Looking up portsnap.FreeBSD.org mirrors... 5 mirrors found.
Fetching public key from dualstack.aws.portsnap.freebsd.org... done.
Fetching snapshot tag from dualstack.aws.portsnap.freebsd.org... done.
Fetching snapshot metadata... done.
Fetching snapshot generated at Tue Dec 13 03:30:41 +03 2022:
fd565c769b680049c9f46cc0011374fba928fe5e253925 98 MB 2927 kBps 34s
Extracting snapshot... done.
Verifying snapshot integrity... done.
Fetching snapshot tag from dualstack.aws.portsnap.freebsd.org... done.
Fetching snapshot metadata... done.
Updating from Tue Dec 13 03:30:41 +03 2022 to Tue Dec 13 11:30:16 +03 2022.
Fetching 5 metadata patches... done.
Applying metadata patches... done.
Fetching 0 metadata files... done.
Fetching 31 patches.
(31/31) 100.00% done.
done.
Applying patches...
done.
Fetching 0 new ports or files... done.
portsnap fetch 60.09s user 68.66s system 90% cpu 2:22.56 total -
By running the next command extract the snapshot into
/usr/ports
when executing Portsnap for the first time.portsnap extract
-
After the first usage of Portsnap has been done as outlined above,
/usr/ports
may be changed as necessary by running the following command:portsnap fetch
portsnap updateThe extract or update operation may be executed concurrently while using fetch, as follows:
portsnap fetch update
How to Install Ports?
This section gives basic methods for installing or removing applications using the Ports Collection.
Before constructing any port, ensure that the Ports Collection has been updated by running portsnap update
. Since the installation of any third-party software might create security vulnerabilities, it is suggested to check http://vuxml.freebsd.org/
for known security concerns associated with the port before installing any third-party software. Alternately, before installing a new port, run pkg audit -F
. During the daily security system check, this command may be set to automatically conduct a security audit and update the vulnerability database.
The Ports Collection requires an active Internet connection to function. Additionally, superuser permission is required.
To build and install the port, go to its installation directory and execute make install at the prompt. For example, to install the nano
software run the following commands.
cd /usr/ports/editors/nano
make install
You should see the output similar to the given below:
........
installing ru.gmo as /usr/ports/editors/nano/work/stage/usr/local/share/locale/ru/LC_MESSAGES/nano.mo
installing sk.gmo as /usr/ports/editors/nano/work/stage/usr/local/share/locale/sk/LC_MESSAGES/nano.mo
installing sl.gmo as /usr/ports/editors/nano/work/stage/usr/local/share/locale/sl/LC_MESSAGES/nano.mo
installing sq.gmo as /usr/ports/editors/nano/work/stage/usr/local/share/locale/sq/LC_MESSAGES/nano.mo
installing sr.gmo as /usr/ports/editors/nano/work/stage/usr/local/share/locale/sr/LC_MESSAGES/nano.mo
installing sv.gmo as /usr/ports/editors/nano/work/stage/usr/local/share/locale/sv/LC_MESSAGES/nano.mo
installing tr.gmo as /usr/ports/editors/nano/work/stage/usr/local/share/locale/tr/LC_MESSAGES/nano.mo
installing uk.gmo as /usr/ports/editors/nano/work/stage/usr/local/share/locale/uk/LC_MESSAGES/nano.mo
installing vi.gmo as /usr/ports/editors/nano/work/stage/usr/local/share/locale/vi/LC_MESSAGES/nano.mo
installing zh_CN.gmo as /usr/ports/editors/nano/work/stage/usr/local/share/locale/zh_CN/LC_MESSAGES/nano.mo
installing zh_TW.gmo as /usr/ports/editors/nano/work/stage/usr/local/share/locale/zh_TW/LC_MESSAGES/nano.mo
if test "nano" = "gettext-tools"; then /bin/mkdir -p /usr/ports/editors/nano/work/stage/usr/local/share/gettext/po; for file in Makefile.in.in remove-potcdate.sin quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot Makevars.template; do install -m 0644 ./$file /usr/ports/editors/nano/work/stage/usr/local/share/gettext/po/$file; done; for file in Makevars; do rm -f /usr/ports/editors/nano/work/stage/usr/local/share/gettext/po/$file; done; else : ; fi
Making install in src
/bin/mkdir -p '/usr/ports/editors/nano/work/stage/usr/local/bin'
install -s -m 555 nano '/usr/ports/editors/nano/work/stage/usr/local/bin'
/usr/bin/make install-exec-hook
cd /usr/ports/editors/nano/work/stage/usr/local/bin && rm -f rnano && ln -s nano rnano
Making install in syntax
/bin/mkdir -p '/usr/ports/editors/nano/work/stage/usr/local/share/nano'
/bin/mkdir -p '/usr/ports/editors/nano/work/stage/usr/local/share/nano/extra'
install -m 0644 extra/ada.nanorc extra/fortran.nanorc extra/haskell.nanorc extra/povray.nanorc extra/spec.nanorc '/usr/ports/editors/nano/work/stage/usr/local/share/nano/extra'
/bin/mkdir -p '/usr/ports/editors/nano/work/stage/usr/local/share/nano'
install -m 0644 asm.nanorc autoconf.nanorc awk.nanorc changelog.nanorc cmake.nanorc c.nanorc css.nanorc default.nanorc elisp.nanorc email.nanorc go.nanorc groff.nanorc guile.nanorc html.nanorc java.nanorc javascript.nanorc json.nanorc lua.nanorc makefile.nanorc man.nanorc markdown.nanorc nanohelp.nanorc nanorc.nanorc nftables.nanorc objc.nanorc ocaml.nanorc patch.nanorc perl.nanorc php.nanorc po.nanorc python.nanorc ruby.nanorc rust.nanorc sh.nanorc sql.nanorc tcl.nanorc tex.nanorc texinfo.nanorc xml.nanorc yaml.nanorc '/usr/ports/editors/nano/work/stage/usr/local/share/nano'
install -m 0644 /usr/ports/editors/nano/work/nano-7.0/doc/nano.1.html /usr/ports/editors/nano/work/stage/usr/local/share/doc/nano
install -m 0644 /usr/ports/editors/nano/work/nano-7.0/doc/rnano.1.html /usr/ports/editors/nano/work/stage/usr/local/share/doc/nano
install -m 0644 /usr/ports/editors/nano/work/nano-7.0/doc/nanorc.5.html /usr/ports/editors/nano/work/stage/usr/local/share/doc/nano
install -m 0644 /usr/ports/editors/nano/work/nano-7.0/doc/sample.nanorc /usr/ports/editors/nano/work/stage/usr/local/share/examples/nano
====> Compressing man pages (compress-man)
===> Installing for nano-7.0
===> Checking if nano is already installed
===> Registering installation for nano-7.0
Installing nano-7.0...
Some shells maintain a cache of commands accessible in directories indicated in the PATH environment variable in order to speed up search operations for the executable file of these commands. Users of the tcsh
shell must execute rehash
in order to utilize freshly installed commands without supplying their complete path:
rehash
Use instead hash -r
for the sh
shell.
During installation, a working subfolder containing all temporary files needed during compilation is generated. Removing this directory conserves disk space and reduces the possibility of future issues when upgrading to a subsequent version of the port. To remove the temporary compilation files run the next command
make clean
You should see the output similar to the given below for our example:
===> Cleaning for pkgconf-1.8.0_1,1
===> Cleaning for gettext-tools-0.21.1
===> Cleaning for libtextstyle-0.21.1
===> Cleaning for nano-7.0
How to Customize Ports Installation?
Some ports give build options that may be used to activate or disable application components, provide security choices, or provide other modifications. security/gpgme
, www/firefox
, and mail/sylpheed-claws
are other examples. Defaulting to prompting the user to pick choices from a menu, the port may halt many times for user involvement if it relies on other ports with adjustable options. To circumvent this and configure the port in a single batch, run the next command within the port skeleton:
make config-recursive
Then, build and install the port by running make install [clean]
.
The all-depends-list
target collects the list of ports to configure when config-recursive
is used. To ensure that all dependence options have been specified, it is advised to execute make config-recursive
until all dependent ports options have been defined and ports options windows no longer show.
There are many methods to return a port's build options menu to add, delete, or modify these settings after the port has been constructed. One option is to go to the directory that contains the port and then type make config
. Another alternative is to use make showconfig
. make rmconfig
will delete all previously specified parameters and enable you to begin over.
The ports system downloads source files using fetch
, which supports several environment variables. If the FreeBSD system is behind a firewall or FTP/HTTP proxy, the FTP PASSIVE MODE, FTP PROXY, and FTP PASSWORD variables may need to be configured.
For users who are not always connected to the Internet, make fetch
may be executed inside /usr/ports
to retrieve all distfiles, within a category, such as /usr/ports/net
, or within the port skeleton itself. Note that if a port has dependents, executing this command inside a category or ports skeleton will not download the distfiles of ports from a different category. Instead, use next command to further get the distfiles for all of a port's dependencies:
make fetch-recursive
In exceptional circumstances, such as when an organization maintains a local distfiles repository, the MASTER SITES option may be used to override the Makefile-specified download destinations. Specify the alternative location when using:
cd /usr/ports/directory
make MASTER SITE OVERRIDE= ftp:/ftp.org/pub/FreeBSD/ports/distfiles/ fetch
The variables WRKDIRPREFIX and PREFIX may alter the default working and destination directories. For instance, the following command will compile the port in /usr/home/example/ports
and install everything under /usr/local
.
make WRKDIRPREFIX=/usr/home/example/ports install
The next command will compile the port in /usr/ports
and install it in /usr/home/example/local
.
make PREFIX=/usr/home/example/local install
And the following command will combine the two.
make WRKDIRPREFIX=../ports PREFIX=../local install
These may be set as environment variables as well.
How to Remove Installed Ports?
You may easily delete an application by running the following command:
make deinstall
For example, to remove nano
run the next commands:
cd /usr/ports/editors/nano
make deinstall
You should see the output similar to the given below for our example:
===> Deinstalling for nano
===> Deinstalling nano-7.0
Updating database digests format: 100%
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):
Installed packages to be REMOVED:
nano: 7.0
Number of packages to be removed: 1
The operation will free 3 MiB.
[1/1] Deinstalling nano-7.0...
[1/1] Deleting files for nano-7.0: 100%
It is important to read the warnings before uninstalling the port. If the port is required by any apps, this information will be presented, but the port will still be uninstalled. In such situations, it may be preferable to reinstall the program to avoid damaged dependencies.
How to View Installed Ports?
To display just the apps installed using the make command from the ports collection, use the following command:
pkg query -a '%n %R' | grep 'unknown-repository' | cut -d ' ' -f1
The following command may be used to examine a list of installed apps, although it will display both applications installed through the ports collections and those installed via the FreeBSD repository, which includes precompiled copies of the ports collection.
pkg info
How to Upgrade Ports?
Newer versions of the software are added to the Ports Collection over time. This section explains how to discover whether software can be updated and how to upgrade it.
Verify that the most recent version of the ports tree is installed using the updating command outlined in "Git Method" to discover whether newer versions of installed ports are available. On FreeBSD 10 and later, or if the system has been converted to pkg, the command below will list out-of-date installed ports:
pkg version -l "<"
Before trying an upgrade, read /usr/ports/UPDATING
from the top to the date corresponding to the last time ports were upgraded or the system was installed. This file discusses numerous concerns and extra actions that users may experience and be required to do while upgrading a port, such as file format changes, changes in the locations of configuration files, and any version incompatibilities. Notate any instructions that correspond to any of the ports requiring an update, and adhere to these instructions while completing the upgrade.
The Ports Collection includes the following tools for doing the actual upgrading:
-
Portmaster
-
Portupgrade
-
Synthesis
Each has its own advantages and disadvantages. Historically, the majority of installations have used either Portmaster or Portupgrade. Synthesis is a modern substitute. It is up to the system administrator to choose which tool is ideal for a certain system. Before using any of these programs, it is best practice to back up your data.
How to Upgrade Ports with Portmaster?
The ports-mgmt/portmaster
package or port is the preferred tool for updating installed ports since it is intended to utilize the FreeBSD utilities without requiring additional ports. It utilizes the contents of the /var/db/pkg
directory to decide which ports to update. To install portmaster as a port run the next commands:
cd /usr/ports/ports-mgmt/portmaster
make install clean
Portmaster identifies four port categories:
-
Root port: Root port has no dependents and no dependencies.
-
Trunk port: The trunk port has no dependents, but is dependent on other ports.
-
Branch port: Branch port has dependencies and is dependent on other ports.
-
Leaf port: Leaf port has dependencies but is not dependent on any other port.
To list these categories and look for updates run the next command:
portmaster -L
You should see the output similar to the one given below for our example:
===>>> Root ports (No dependencies, not depended on)
===>>> dialog4ports-0.1.6_1
===>>> pkg-1.19.0
===>>> pkgconf-1.8.0_1,1
===>>> portmaster-3.22
===>>> 4 root ports
===>>> Trunk ports (No dependencies, are depended on)
===>>> autoconf-switch-20220527
===>>> db5-5.3.28_9
===>>> indexinfo-0.3.1
===>>> libedit-3.1.20221030,1
===>>> libiconv-1.17
===>>> libunwind-20211201_1
===>>> libyaml-0.2.5
===>>> perl5-5.32.1_3
===>>> 8 trunk ports
===>>> Branch ports (Have dependencies, are depended on)
===>>> autoconf-2.71
===>>> gettext-runtime-0.21.1
===>>> libffi-3.4.4
===>>> libtextstyle-0.21.1
===>>> m4-1.4.19,1
===>>> p5-Locale-gettext-1.07
===>>> p5-Locale-libintl-1.32
===>>> p5-Text-Unidecode-1.30
===>>> p5-Unicode-EastAsianWidth-12.0
===>>> ruby-3.0.5,1
===>>> ruby30-bdb-0.6.6_8
===>>> ruby30-gems-3.3.23
===>>> rubygem-psych-4.0.6
===>>> rubygem-stringio-3.0.2
===>>> 14 branch ports
===>>> Leaf ports (Have dependencies, not depended on)
===>>> automake-1.16.5
===>>> gettext-tools-0.21.1
===>>> gmake-4.3_2
===>>> help2man-1.49.2
===>>> portupgrade-2.4.16,2
===>>> rubygem-rdoc-6.5.0
===>>> texinfo-6.8_3,1
===>>> 7 leaf ports
===>>> 33 total installed ports
===>>> There are no new versions available
You may run the following command to update all outdated ports:
portmaster -a
Before removing an existing port, Portmaster creates a backup package by default. If the new version is successfully installed, Portmaster will remove the backup. Using -b
will advise Portmaster not to destroy the backup automatically. By appending -i
, Portmaster will launch in interactive mode, requesting consent before updating each port. There are several alternatives accessible.
You may add -f
to upgrade and rebuild all ports if an issue occurs during the upgrading process:
portmaster -af
Portmaster may also be used to install new ports, updating all dependencies prior to constructing and installing the new port. To use this feature, define the port's location in the Ports Collection:
portmaster shells/bash
How to Upgrade Ports with portupgrade ?
ports-mgmt/portupgrade
is an additional tool for upgrading ports. It installs a collection of port-management software. However, it is dependant upon Ruby.
To install the portupgrade
port run the next commands:
cd /usr/ports/ports-mgmt/portupgrade
make install clean
Use the following command to upgrade any obsolete ports installed on the system.
portupgrade -a
Alternately, add -i
to request confirmation of each individual upgrade:
portupgrade -ai
Use portupgrade pkgname
to upgrade a single program instead of all accessible ports. It is crucial to add -R in order to first update all ports needed by the provided application:
portupgrade -R firefox
If -P
is used, Portupgrade scans the local directories indicated in PKG PATH for available packages. If none are accessible locally, packages are downloaded from a distant server. If no packages can be located locally or remotely, Portupgrade will use ports. Specify -PP
to avoid using ports completely. This last set of settings instructs Portupgrade to abort if there are no accessible packages:
portupgrade -PP gnome3
Use -F
to get just the port distribution files, or packages if -P
is provided, without building or installing anything.
How to Manage Disk Size With Ports?
Using the Ports Collection will eventually use disk space. After a port has been built and installed, executing make clean
inside the ports skeleton will clear the temporary work directory. Unless -K
is given, Portmaster will automatically destroy this directory after installing a port. If Portupgrade is installed, the following command deletes all work folders from the local copy of the Ports Collection:
portsclean -C
You should see the output similar to the one given below for our example:
Cleaning out /usr/ports/*/*/work...
Delete /usr/ports/converters/p5-Text-Unidecode/work
Delete /usr/ports/databases/db5/work
Delete /usr/ports/databases/ruby-bdb/work
Delete /usr/ports/devel/autoconf/work
Delete /usr/ports/devel/autoconf-switch/work
Delete /usr/ports/devel/automake/work
Delete /usr/ports/devel/gmake/work
Delete /usr/ports/devel/libedit/work
Delete /usr/ports/devel/libffi/work
Delete /usr/ports/devel/libunwind/work
Delete /usr/ports/devel/m4/work
Delete /usr/ports/devel/p5-Locale-gettext/work
Delete /usr/ports/devel/p5-Locale-libintl/work
Delete /usr/ports/devel/ruby-gems/work
Delete /usr/ports/devel/rubygem-rdoc/work
Delete /usr/ports/devel/rubygem-stringio/work
Delete /usr/ports/lang/perl5.32/work
Delete /usr/ports/lang/ruby30/work
Delete /usr/ports/misc/help2man/work
Delete /usr/ports/ports-mgmt/portupgrade/work
Delete /usr/ports/print/texinfo/work
Delete /usr/ports/textproc/libyaml/work
Delete /usr/ports/textproc/p5-Unicode-EastAsianWidth/work
Delete /usr/ports/textproc/rubygem-psych/work
done.
Additionally, obsolete source distribution files gather over time in /usr/ports/distfiles
. To remove all distfiles that are no longer referenced by any ports using Portupgrade run the next command:
portsclean -D
Portupgrade may delete any distfiles not presently referenced by any installed port:
portscleaning -DD
You may use the next command delete distfiles if Portmaster is installed:
portmaster - -clean-distfiles
This command is interactive by default and requests the user for confirmation before deleting a distfile.
In addition to these operations, ports-mgmt/pkg_cutleaves
automates the removal of no longer required installed ports.
How to Build Packages with Poudriere?
Poudriere is a BSD-licensed application for developing and testing FreeBSD packages. It establishes isolated compilation environments using FreeBSD jails. These jails may be used to produce packages for FreeBSD versions other than the one installed on the host system, as well as packages for i386 if the host is an amd64 machine. Once the packages have been constructed, their layout is similar to that of the official mirrors. These packages are compatible with pkg
and other package management tools.
Installing Poudriere requires the ports-mgmt/poudriere
package or port.
pkg install poudriere
The installer contains the /usr/local/etc/poudriere.conf.sample
example configuration file. This file should be copied to /usr/local/etc/poudriere.conf
.
cp /usr/local/etc/poudriere.conf.sample /usr/local/etc/poudriere.conf
Edit the transferred file to suit the local environment.
ZFS is not necessary for systems running poudriere, however it is recommended. ZPOOL must be defined in /usr/local/etc/poudriere.conf
and FREEBSD HOST must be set to a nearby mirror when ZFS is utilized. CCACHE DIR allows the usage of devel/ccache
to cache compilation and minimize build times for code that is regularly built. Putting poudriere datasets in an isolated tree mounted at /poudriere
may be handy. The other configuration settings' default values are appropriate.
ZPOOL=zroot
FREEBSD_HOST=ftp://ftp.freebsd.org
The number of identified CPU cores is used to determine the number of concurrently running builds. Provide sufficient virtual memory through RAM or swap space. If virtual memory is exhausted, compilation jails will cease and be destroyed, producing bizarre error messages.
How to Initialize Jails and Port Trees?
Initialize poudriere so that it installs a jails with the needed FreeBSD tree and a ports tree after configuration. Specify the jail's name with the -j
option and the FreeBSD version with the -v
option. On systems running FreeBSD/amd64, -a
may be used to change the architecture to either i386 or amd64. The default architecture is determined by uname
.
poudriere jail -c -j 13amd64 -v 13.1-RELEASE
You should see the output similar to the given below:
[00:00:00] Creating 13amd64 fs at /usr/local/poudriere/jails/13amd64... done
[00:00:01] Using pre-distributed MANIFEST for FreeBSD 13.1-RELEASE amd64
[00:00:01] Fetching base for FreeBSD 13.1-RELEASE amd64
/usr/local/poudriere/jails/13amd64/fromftp/bas 186 MB 2652 kBps 01m12s
[00:01:15] Extracting base... done
[00:01:39] Fetching src for FreeBSD 13.1-RELEASE amd64
/usr/local/poudriere/jails/13amd64/fromftp/src 183 MB 2850 kBps 01m06s
[00:02:48] Extracting src... done
[00:03:22] Fetching lib32 for FreeBSD 13.1-RELEASE amd64
/usr/local/poudriere/jails/13amd64/fromftp/lib 63 MB 2810 kBps 23s
[00:03:47] Extracting lib32... done
[00:03:53] Cleaning up... done
[00:03:56] Recording filesystem state for clean... done
[00:03:56] Upgrading using http
/etc/resolv.conf -> /usr/local/poudriere/jails/13amd64/etc/resolv.conf
Looking up update.FreeBSD.org mirrors... 2 mirrors found.
Fetching public key from update1.freebsd.org... done.
Fetching metadata signature for 13.1-RELEASE from update1.freebsd.org... done.
Fetching metadata index... done.
Fetching 2 metadata files... done.
Inspecting system... done.
Preparing to download files... done.
Fetching 290 patches.....10....20....30....40....50....60....70....80....90....100....110....120....130....140....150....160....170....180....190....200....210....220....230....240....250....260....270....280....290 done.
Applying patches... done.
Fetching 1 files... done.
The following files will be removed as part of updating to
13.1-RELEASE-p5:
/usr/share/zoneinfo/SystemV
/usr/src/contrib/tzdata/pacificnew
/usr/src/contrib/tzdata/systemv
/usr/src/contrib/tzdata/yearistype.sh
/usr/src/contrib/tzdata/zoneinfo2tdf.pl
/var/db/etcupdate/current/etc/mtree/BSD.usr.dist
/var/db/etcupdate/log
/var/db/mergemaster.mtree
Installing updates...Scanning //usr/share/certs/blacklisted for certificates...
Scanning //usr/share/certs/trusted for certificates...
done.
13.1-RELEASE-p5
[00:05:05] Recording filesystem state for clean... done
[00:05:05] Jail 13amd64 13.1-RELEASE-p5 amd64 is ready to be used
poudriere ports -c -p local -m git+https
You should see the output similar to the given below:
[00:00:00] Creating local fs at /usr/local/poudriere/ports/local... done
[00:00:00] Cloning the ports tree... done
Poudriere can construct ports with many configurations, in several jails, and from separate port trees on a single machine. Sets are custom settings for certain pairings.
This setup puts a single make.conf
file in /usr/local/etc/poudriere.d
that is jail-
, port-
, and set-specific
. 13amd64-local-workstation-make.con
f is the filename formed by combining the jail name, port name, and set name in this case. At build time, the system make.con
f and this new file are concatenated to form the build jail's make.conf
.
In 13amd64-local-workstation-pkglist, packages to be built are entered:
editors/emacs
devel/git
ports-mgmt/pkg
...
Options and dependencies are set up for the provided ports:
poudriere options -j 13amd64 -p local -z workstation -f 13amd64-local-workstation-pkglist
Finally, packages are constructed and a repository for packages is created:
poudriere bulk -j 13amd64 -p local -z workstation -f 13amd64-local-workstation-pkglist
During execution, pressing Ctrl+t
reveals the current construction status. Additionally, Poudriere generates files in /poudriere/logs/bulk/jailname
that a web server might utilize to show construction information.
The revised packages are now available for installation from the poudriere repository upon completion.
How to Configure pkg Clients to Integrate with a Poudriere Repository?
Although it is possible to utilize both a custom repository and the official repository simultaneously, it is occasionally advantageous to deactivate the official repository. This is achieved by the creation of a configuration file that replaces and disables the official configuration file. Create the file /usr/local/etc/pkg/repos/FreeBSD.conf
with the following content:
FreeBSD:{ enabled: no enabled }
HTTP is often the most efficient method for serving a poudriere repository to client computers. Configure a webserver to serve the package directory, for example: /usr/local/poudriere/data/packages/13amd64
, where 13amd64
is the build's name.
If the package repository URL is http://pkg.example.com/13amd64
, then the repository configuration file in /usr/local/etc/pkg/repos/custom.conf
would be:
custom: {
url: "http://pkg.example.com/13amd64",
enabled: yes,
}
What are the Post Installation Considerations?
Most third-party programs need some amount of setup after installation, regardless of whether the product was installed from a binary package or port. The following commands and locations may be used to identify which components of the program were installed:
-
The documentation provided by apps is installed in
/usr/local/share/doc
, and many applications additionally install instructional pages. This material should be reviewed prior to proceeding. -
The majority of apps install at least one configuration file by default in
/usr/local/etc
. When an application has several configuration files, a subfolder will be created to store them. Frequently, sample configuration files with a suffix such as.sample
are installed. The configuration files should be examined and, if necessary, modified to accommodate the system's requirements. Before you may modify a sample file, you must first copy it without the.sample
suffix. -
Some programs execute services that must be added to
/etc/rc.conf
before the application may be launched. Typically, these programs will install a startup script in/usr/local/etc/rc.d
.tipBy design, apps never execute their startup script during installation nor their stop script during uninstallation or upgrading. This choice is left to the discretion of each system administrator.
-
Utilize
pkg info
to identify which files, man pages, and binaries were installed with a program. -
Users of
csh
must executerehash
to recreate the known binary list in the PATH environment variable.