OpenBSD Ports - How to Use dan Update Ports Collection

The port system in OpenBSD is not completely the same compared to the port system in FreeBSD. This is due to the developer only including tested and stable applications into the port, in other words there are no development branches etc. Untested and unstable applications are rarely included in the OpenBSD repository. Even though using the application in the OpenBSD port is stable, we recommend that you use the pkg package.

On the OpenBSD operating system, there is a lot of software that you can install. However, due to space limitations and to speed up the installation process, most of the software is provided via the OpenBSD port pool. The port collection includes software packages that you can download, compile, and install.

The first step to use the port system on an OpenBSD server, you must have the ports.tar.gz file. This file contains a collection of software that you can install. Usually the ports.tar.gz file is found on the OpenBSD installation CD. If you don't have it, you can download it from the OpenBSD or Github repository. You need to pay attention, using this ports system is a bit difficult compared to the pkg package. The ports system is intended for advanced users.

This article will show you how to configure an OpenBSD 7.5 system to retrieve the latest version from the ports repository, and how to install software from the ports collection.



1. installing ports

On OpenBSD system ports are not built automatically when you install OpenBSD. You must download the system ports and save them in the /usr directory. Below we provide a guide to downloading ports on OpenBSD 7.5.

Download ports
foo# cd /tmp
foo# ftp https://cdn.openbsd.org/pub/OpenBSD/$(uname -r)/{ports.tar.gz,SHA256.sig}
foo# signify -Cp /etc/signify/openbsd-$(uname -r | cut -c 1,3)-base.pub -x SHA256.sig ports.tar.gz
The above command is used to download the ports.tar.gz file. After the download is complete, execute the extract command and save the extracted file in the /usr/ports directory.

Extract ports.tar.gz file
foo# cd /usr
foo# tar xzf /tmp/ports.tar.gz
After you have successfully extracted the ports.tar.gz file, continue by updating the ports system. To update ports to the stable version, use the CVS command. Choose the mirror closest to your city. We will provide an example of how to update ports with CVS.

Update ports
foo# cd /usr/ports
foo# cvs -qd anoncvs@anoncvs1.usa.openbsd.org:/cvs checkout -rOPENBSD_7_5 -P ports

Or, you can also use the spacehopper.org mirror

foo# cvs -qd anoncvs@anoncvs.spacehopper.org:/cvs checkout -rOPENBSD_7_5 -P ports
Below are some mirrors that you can use:
  1. anoncvs@anoncvs.usa.openbsd.org:/cvs
  2. anoncvs@anoncvs5.usa.openbsd.org:/cvs
  3. anoncvs@mirror.arc.nasa.gov:/cvs
  4. anoncvs@anoncvs6.usa.openbsd.org:/cvs
  5. anoncvs@anoncvs1.ca.openbsd.org:/cvs
  6. anoncvs@valkyrie.secureops.com:/cvs
  7. anoncvs@anoncvs.uk.openbsd.org:/cvs
  8. anoncvs@anoncvs.tw.openbsd.org:/cvs
To complete the update process, run the command below.

Complete update ports
foo# cvs -q up -Pd -rOPENBSD_7_5

2. Configuration OpenBSD ports

In this section we will carry out global settings for building the port. This prevents multiple "make" statements from appearing when you use ports. The port infrastructure can be run as a normal user, but we recommend that you use the superuser as root. Unless, you have finished installing the software, and started configuring the software.

It is possible to use a read-only ports tree by separating directories that are written to during port building:
  1. The working directory of ports. This is controlled by the WRKOBJDIR variable, which specifies the directory which will contain the working directories.
  2. The directory containing distribution files. This is controlled by the DISTDIR variable.
  3. The directory containing newly built binary packages. This is controlled by the PACKAGE_REPOSITORY variable.
To use all these variables, you can add the script below to the /etc/mk.conf file.

Write variables
foo# touch /etc/mk.conf
foo# nano /etc/mk.conf
WRKOBJDIR=/usr/obj/ports
DISTDIR=/usr/distfiles
PACKAGE_REPOSITORY=/usr/packages

3. Searching software with ports

As explained above, the ports system can be run by ordinary users. If you wish, change the ownership of the ports directory to your local user and group name, so that the ports system can create the underlying working directory as a normal user. But you need to remember, the port can be built as a normal user, but must be installed by the root user or with doas.

To run duas, you don't have to install duas, just activate it. Doas can be activated with the doas.conf file. Create a duas.conf file and add the script below to the duas.conf file. Follow the commands below to create and add a script into the duas.conf file.

Create and write script doas.conf
foo# touch /etc/doas.conf
foo# nano /etc/doas.conf
#permit persist setenv { PKG_CACHE PKG_PATH } aja cmd pkg_add
permit setenv { -ENV PS1=$DOAS_PS1 SSH_AUTH_SOCK } :wheel
permit nopass tedu as root cmd /usr/sbin/procmap
permit nopass keepenv setenv { PATH } root as root

permit nopass setenv { \
    FTPMODE PKG_CACHE PKG_PATH SM_PATH SSH_AUTH_SOCK \
    DESTDIR DISTDIR FETCH_CMD FLAVOR GROUP MAKE MAKECONF \
    MULTI_PACKAGES NOMAN OKAY_FILES OWNER PKG_DBDIR \
    PKG_DESTDIR PKG_TMPDIR PORTSDIR RELEASEDIR SHARED_ONLY \
    SUBPACKAGE WRKOBJDIR SUDO_PORT_V1 } :wsrc

# Allow wheel by default
#permit keepenv :wheel
After that, run the command below.

/usr/ports
foo# cd /usr/ports
foo# doas pkg_add portslist
quirks-7.14 signed on 2024-03-17T12:22:05Z
portslist-7.52: ok
Once you have enabled dos and have a port tree and port list package on the OpenBSD system. Executing software search commands becomes very easy. Just use make search key="searchkey" as shown in this example.

Searching software
foo# make search key=apache
The command above, is used to search for apache software. Below we give several examples of how to search for software in ports.

Searching software
foo# make search key=nginx
foo# make search key=isc-bind
foo# make search key=freeradius

4. Install and remove software with ports

Maybe this is the last part of the content of our article. In this section we will learn how to install and uninstall software using OpenBSD ports. Below we provide an example of how to install Nginx software.

Install Nginx
foo# cd /usr/ports/www/nginx
foo# make build
foo# make install
foo# make clean
Below we will give another example of how to install Bash.

Install Bash
foo# cd /usr/ports/shells/bash
foo# make build
foo# make install
foo# make clean
It wouldn't be complete if it didn't explain how to delete software in OpenBSD. We will explain how to uninstall software in OpenBSD. Follow the command guide below to uninstall software in OpenBSD.

Uninstall Nginx
foo# cd /usr/ports/www/nginx
foo# make uninstall
foo# make clean=packages
Below, we also demonstrate how to delete Bash.

Uninstall Bash
foo# cd /usr/ports/shells/bash
foo# make uninstall
foo# make clean=packages
In this article you have learned how to use OpenBSD ports. There are many ways to manage and use OpenBSD ports. We suggest you read other articles to deepen your understanding of the ports system used in OpenBSD.
Iwan Setiawan

I Like Adventure: Mahameru Mount, Rinjani Mount I Like Writer FreeBSD

Post a Comment

Previous Post Next Post