OpenBSD Package System
Introduction
Transitioning to OpenBSD isn’t very straightforward when coming from the Linux world (PS: if you’re coming from Windows, it’s better to stay there or switch to Linux first).
In OpenBSD, there are two package systems:
- The first one is provided by the base OpenBSD system (pkg), containing packages with almost no security vulnerabilities (just a reminder: only 2 vulnerabilities discovered in 10 years). These packages are pre-compiled.
- The second contains many more software applications (port), but according to OpenBSD, they can compromise system stability and security. That said, it’s still preferable to use these rather than compiling yourself from various sources since these packages have still been validated by the OpenBSD team. These packages are compiled on demand.
PGK
Preparation
First, you need to choose an FTP server to specify the repository. I chose a French server:
|
|
To make this permanent, add this line to your .profile
file.
Installing a package
To install packages, there are several arguments available. I use -i
for interactive mode (available since OpenBSD 3.9) and the -v
option for verbose output. To install postfix, I do:
|
|
I can then choose the version number I want to install. Otherwise, I can directly specify what I want:
|
|
Getting information
To get information about my installed packages, I can use:
|
|
Updating packages
To update packages, just use the pkg_add
command with an argument and the name of the package to update:
|
|
If you add the -c
option, it will overwrite the current configuration files with the default ones.
Removing a package
Again, it’s not very complicated, use the pkg_delete
command followed by the package to remove:
|
|
Upgrade
When there’s a version upgrade, remember to modify your repository line, then do this to update all packages:
|
|
Port
Getting the ports tree
Let’s get the tar.gz and decompress it:
|
|
Configuring the ports system
If you’ve created a new user, add them to the sudoers list, and give them the rights:
|
|
Next, let’s add a few lines to the mk.conf file:
|
|
Searching for packages
To perform a search:
|
|
|
|
Here I don’t have a graphical interface, so I don’t need X11, the no_x11 option is interesting to me.
Installing a package
To install a package, just go to the right section and start the compilation:
|
|
Now let’s see the available options:
|
|
Once again, we can see that I can compile nmap without the graphical interface. I pass my argument before compiling, then run make install:
|
|
Cleaning up after compilation
You probably want to clean up the default working directory of the port after building and installing the package.
|
|
You can also clean the working directories of all the port’s dependencies with this make target:
|
|
If you want to remove all the port’s distribution sources, you can use:
|
|
In case you’ve compiled multiple flavors of the same port, you can clean the working directories of all these flavors at once using:
|
|
Last updated 27 Nov 2007, 18:07 +0200.