PKGNG – The future of packages on FreeBSD and PC-BSD

This article will show how to install, upgrade and remove packages using pkgng. It will also discuss some of the improvements over pkg_*tools and demonstrate how pkgng will benefit end users. In addition, the upcoming functionality of pkgng will also be briefly discussed. Finally, it will show how to install Gnome 3 and Cinnamon on PC-BSD Rolling Release using Pkgdemon.

All of you want to know how to use a third party package repository. This article will use Pkgdemon with the PC-BSD Rolling Release as an example to demonstrate the process. This article will show the process of adding a package site and then installing packages on the PC-BSD Rolling Release. The same information can be applied to a fresh install of FreeBSD 9.1 onward, or a FreeBSD 9.1 installation where pkgng was used to install all previously installed packages. It will cover basic maintenance tasks. It will also demonstrate the advantages of using the new package system as well as its future potential.

Before PKGNG

Users of FreeBSD and derivative systems have always had primarily two ways of installing software. The first one is through the use of ports and building binaries from source code. The second one is by using packages. Anyone who has ever installed packages before on FreeBSD, will be familiar with the problems associated with using pkg_*tools. This may be one of the many reasons most users choose to stick with ports. While installation of software by ports is often ideal for servers and advanced users, it is not often ideal for a user who wants or needs a desktop that works out of the box.

A good example for me is when I need to provision a new machine for work purposes. I need to be able to get it installed quickly, so I can begin to look up customers and troubleshoot issues. I don’t have time to wait around for a couple of days or have a half-usable system until all of the software is installed. So for me, installing from packages on a desktop is a perfect solution.

At my workplace, we have used FreeBSD on our servers or years and we love it for its rock-solid stability, security, and portability. A few of us experimented with the idea of using FreeBSD as a desktop a few times at work. However, it became clear that as much as we loved FreeBSD, none of us could afford the downtime. Then PC-BSD came along with a few really solid releases, starting with 8.0, and that really began to meet our needs. PC-BSD has, of course, solved many of the problems associated with using packages by developing a third method called PBI. This self-contained method allows quick installation of many desktops and even certain server applications. It has allowed me and others to use Free- BSD at work on our desktops.

However, PC-BSD has also relied on using packages for its desktop interfaces quite often. The shortcomings of pkg_*tools are less noticeable, but nonetheless are still noticeable, when it comes to exceptionally long installation times and software upgrades. It would become even more noticeable if a user were to try to install software themselves through packages. Package conflicts could occur and a user could easily break their entire desktop.

For example, to upgrade from PC-BSD 9.0 release to 9.1, release packages would have to be manually deleted behind the scenes. In addition, the PC-BSD operating system had to know what packages a user had installed. If a user had installed their own packages or ports, they would have to be removed behind the scenes. If the PC-BSD installer had not done this, the entire desktop could be broken. As a result, if a user has additional ports or packages that are not part of the PC-BSD installation, they will be deleted during an upgrade. This was not a huge issue, it was just an obvious limitation of pkg_*tools.

pkg_*tools and third party repositories

To give further examples of pkg_*tools issues, I will use my website: Pkgdemon. Pkgdemon is a 3rd party package repository for FreeBSD, GhostBSD, and PC-BSD. The purpose of Pkgdemon right now is to provide early access to easily-installable Gnome 3 and Cinnamon packages. When I started Pkgdemon, these ports were not yet available in the ports tree, and I wanted to use them at work on my PC-BSD desktop. Knowing that I couldn’t afford to have a lot of downtime at work, I devised a way to make the installation easy enough so I could install it on my work system. After compiling ports into packages, there was one obvious problem. Installing Gnome 3 from using pkg_*tools is not easy if you have other packages installed which conflict with Gnome 3. Even if you know what the names of the packages are, it is still not easy. For example, for each pkg, you would have to list the entire name of the package.  You are also likely to have to force the package to uninstall. Here is an example of one (out of the hundred) pkg_delete commands required for installation on PCBSD 9.1 Isotope.
pkg_delete -f py27-dbus-0.84.0

You may be thinking that I could have recursively deleted Gnome 2 and all of its dependencies. However, this would break both my installation and the Nvidia drivers, as deleting Gnome 2 recursively would have uninstalled components required by Nvidia and Xorg.  This was not an option for this script. This situation was somewhat eased later by pkgng as you will see later in this article.

I had to create executable shell scripts to remove the several hundreds of packages.  In addition, occasionally other packages that were outside of my Gnome 3 repository were more recent versions than what Gnome 3 expected. For example, Gnome 3 expected that libpcre. so.1 and libpcre.so.3 were installed. I had to manually create symbolic links within the script. I had to do this for a few other libraries as well otherwise the package installation would fail and several applications would not open. This is no longer necessary as often,with pkgng.

In addition, I wanted to be able to host other desktops for installation besides Gnome 3. For now, the additional desktop is Cinnamon.  In the future, I want to add Mate, possibly CDE, and some others. To make that easy, I had to create an interactive menu within the shell script to allow the user to choose which combination of desktops to install. This is also no longer necessary with pkgng.

When I had made changes to the ports tree, I forked Gnome 3 for packaging purposes. I needed to devise a way to give myself and others an upgrade path. This involved adding a list of packages that were installed by Gnome 3 or Cinnamon and making sure those were removed as well. If I had forgotten a package it would become obvious as the script would fail during installation. This was also drastically eased by pkgng.

Listing 1 is what the script would look like in a terminal. Without this script, users would have to manually remove hundreds of packages by hand in order to install Gnome 3 using packages created by pkg_*tools. The source code for this script showing the commands can be viewed here: https://github.com/pkgdemon/freebsd-pkgdemon/blob/master/PCBSD9.1-x64-pkgdemon-v1.01.sh. If you need the x86 version of the script, please go to the Pkgdemon github url: http://www.github.com/pkgdemon/freebsd-pkgdemon

PKGNG

PKGNG is referred to as the next generation package manager. It uses a SQLite database to store all of the info about the installed packages on your system. The location of the database still resides in /var/db/pkg, but now as a single file. This is in contrast to otherwise what would be many folders and files containing information about the installed packages.

Storing the information about packages in a database makes searching for information about installed packages fast. It also helps make installation and removal fast, and it allows for easier upgrades. I could go on about the technical details of what makes pkgng so great, however, nothing will show it as well as using it. To do that, I must introduce PC-BSD rolling release and try to explain briefly what it is.

PC-BSD Rolling Release

Some time ago, Kris Moore announced that PC-BSD would be adding a rolling release model in addition to the current stable releases. The current stable release is PC-BSD 9.1 Isotope. As part of this release announcement, it was mentioned that PC-BSD would begin using pkgng, and that all of the packages would be converted to pkgng.

In addition to this, it was mentioned that a pkgng repository would be created for upgrades of system packages. This meant that if a new version of KDE or a new version of Xorg were released into FreeBSD ports that, if you were running the rolling release, you could upgrade to them as they periodically rebuild the packages for the repository. That is as opposed to having to wait for the next stable PC-BSD release. This currently only happens about every year or so when a new release of FreeBSD occurs. To get a rough idea of what types of commands, how many packages might have to be removed, and what might be required to upgrade to a new version of KDE or Xorg using pkg-tools, please take a look at script from Listing 1. With pkgng, it is just one command.
pkg upgrade
If that isn’t a huge reason to switch to pkgng over pkg_*tools right now, what is?

Adding a third party repository

Now I am going to show the installation process for Pkgdemon using PC-BSD Rolling Release. I was told that eventually there will be a special page on the PC-BSD website for the Rolling Release with download links. A few download links will be included at the end of the article for Rolling Release.
Before following this guide please remove XFCE, LXDE, and Gnome. If you are doing a fresh install, do not select either of these or the following commands will remove these packages.
pc-metapkgmanager del GNOME
pc-metapkgmanager del GNOME-Accessibility
pc-metapkgmanager del GNOME-Games
pc-metapkgmanager del GNOME-Net
pc-metapkgmanager del GNOME-Utilities
pc-metapkgmanager del XFCE
pc-metapkgmanager del XFCE-Plugins
pc-metapkgmanager del LXDE
pkg autoremove

The pc-metapkgmanager commands are specific to PC-BSD; however, the pkg autoremove command is specific to pkgng. In this example, pc-metapkgmanager will only remove a single package, not all of its dependencies.  Executing pkg autoremove will remove all of the dependencies required by Gnome 2, XFCE, and LXDE. Before, this would have also removed things required for the Nvidia driver and Xorg. This is no longer the case with pkgng, unless those packages are also removed before executing pkg autoremove.

After PC-BSD is installed, it is recommended you login to either the Fluxbox or KDE window manager and open a terminal. The first step will be to add the pkg repo key, which is used for verification.

To use the package signing key you will need to fetch it into /usr/local/etc/. For example:
cd /usr/local/etc
fetch http://www.pkgdemon.com/downloads/pkgdemon.cert

After this, you will need to edit /usr/local/etc/pkg.conf and comment the following lines like this example.
#packagesite: http://pkg.cdn.pcbsd.org/9.1-RELEASE/amd64
#HTTP_MIRROR: http
#PUBKEY: /usr/local/etc/pkg-pubkey.cert

Add the public cert key for pkgdemon to pkg.conf.
PUBKEY: /usr/local/etc/pkgdemon.cert
Then, add the appropriate line below to pkg.conf, depending on which architecture you used to install PCBSD rolling release. PCBSD Rolling Releases are now only available for 64 bit systems.
packagesite: http://www.pkgdemon.com/freebsd:9:x86:64/latest
There are still a few packages, however, that will have to be removed manually as the versions of these packages cannot be removed automatically by pkgng. The following packages are not yet built to be upgrade aware. Therefore they must be removed manually first. The -f flag is used to force removal. If -f is not specified, the packages will not remove as they are required by pcbsd-base.
pkg delete -fy at-spi
pkg delete -fy zenity
pkg delete -fy gnome-session
pkg delete -fy metacity
pkg delete -fy gdm
pkg delete -fy evolution-data-server
pkg delete -fy gnome-desktop
pkg delete -fy gnome-panel
pkg delete -fy gnome-settings-daemon
pkg delete -fy libgnomekbd
pkg delete -fy gnome-power-manager
pkg delete -fy gnome-keyring
pkg delete -fy libgweather
pkg delete -fy gnome-menus
pkg delete -fy libwnck
pkg delete -fy gnome-control-center
pkg delete -fy farsight2

The -y flag will automatically confirm the removal of each package so that you are not prompted to type y to remove each package.
You should notice a couple of things here. One is that the list of packages to delete is dramatically smaller than it would be with pkg_*tools. In fact, hundreds of packages less than when the script was removing the conflicting desktops for you and there were still hundreds of packages to remove. The second thing you should notice is that when you type pkg delete, you no longer have to include the exact version.

Upgrade packages

pkg upgrade -fy
It is safer to use -f flag here to force the upgrade of these packages. This will force an upgrade of the entire package set to ensure compatibility with Gnome 3. Otherwise certain packages necessary for this example may not successfully install and Gnome 3 will crash when launching. The -y flag is used again to automatically confirm to make installation easier.

Install Packages

After the packages have been upgraded, run the following command to install Gnome 3.
pkg install gnome3
Installing Cinnamon is also fairly straightforward.
pkg install cinnamon
You may notice that I am not going to tell you to create a symbolic link with my rolling release instructions. Pkgng is smart enough to figure out what version of pcre Gnome 3.4 wants.

Package removal

The way package removal works with pkgng is much better. If you wanted to remove my Gnome 3 and Cinnamon packages and go back to using what’s provided by PCBSD, it’s fairly easy to do.
pkg remove gnome3
pkg autoremove
pkg remove cinnamon
pkg autoremove

Then just set your packagesite and cert file back to what was provided by PC-BSD. If you just commented the lines, you can uncomment them.
packagesite: http://pkg.cdn.pcbsd.org/9.1-RELEASE/amd64
HTTP_MIRROR: http
PUBKEY: /usr/local/etc/pkg-pubkey.cert

Now comment or delete the lines for Pkgdemon.
#packagesite: http://www.pkgdemon.com/freebsd:9:x86:64/latest
#PUBKEY: /usr/local/etc/pkgdemon.cert
pkg upgrade -fy


Future pkgng features

It has been announced that pkgng will soon be getting some additional features, not entirely covered here. It essentially provides a solid support to a graphical user interface so that installing packages can become available for starters.
Currently, using my installation guide and the rolling release, you will have to replace PC-BSD’s repo with my repo in order to install packages from Pkgdemon. An upcoming feature will allow upgrading across multiple repositories.  This means you should be able to reference both PC-BSD’s repository and my repository to get the latest packages from both Pkgdemon and PC-BSD.

Conclusion

Pkgng is a 21st century package system for FreeBSD.  It will soon allow using multiple repositories concurrently for upgrading and software installation. It will prove to be beneficial for end users by providing easy installation and upgrades of software for FreeBSD using the packages system.

About the Author

Joe Maloney lives in the United States with his family. He works as an Assistant Network Administrator for an Internet Service Provider at Sumner Communications. He likes to hang out on IRC on the Freenode network in the #PCBSD, GhostBSD, and FreeBSD- Gnome channels as malco_2001.

This article was re-published with the permission of BSD Magazine.  To Learn More about iXsystem’s commitment to open source check us out here:   https://www.ixsystems.com/about-ix/

Join iX Newsletter

iXsystems values privacy for all visitors. Learn more about how we use cookies and how you can control them by reading our Privacy Policy.
π