This ports tree contains most of the popular open source applications that are available today. These applications can be updated regularly and it would be a huge hassle to constantly check the Web in case a new version of one of your installed packages has been released. This is where the amazing freshports.org comes to the rescue. Freshports is a neat web site dedicated to FreeBSD's ports tree. You can subscribe to Freshports, and set up a list of watched ports, and then whenever one of your watched ports is upgraded you get an email notification of it! Then all you have to do is sync your ports tree, and upgrade your port. Which brings me to the next subject, package maintenance. As we saw above, pkg_add installs binary packages, and if used with the -r flag it will download the package for you (eg. pkg_add -r bash2 will download and install bash version 2). Now that we have installed a few packages/ports, type "pkg_info | more" to get a listing of installed software. Don't be surprised if the "| more" becomes necessary before too long. Also notice that both packages that you installed with pkg_add and also posts that you compiled via the ports tree both show up, pkg_info doesn't care which way they were installed.
Now we need to delve back into the ports tree again, this time to /usr/ports/sysutils/portupgrade. This extremely handy application takes care of upgrading a previously installed port. Lets say that after installing vim, we get an email from Freshports telling us that the vim port has been updated. So all we have to do is type "pkg_info | grep vim" to get the "proper" package name for vim (eg. the output I get from this is vim-6.0.185). Then all you have to do is type "portupgrade vim-6.0.185" and goes about the process of downloading, compiling, and upgrading vim. If portupgrade reports that vim doesn't need upgrading, make sure you cvsup'd your ports tree recently. The tar files that are downloaded from the Internet to be compiled are stored in /usr/ports/distfiles, if your short on disk space that directory is a good place to reclaim disk space. Also note that by installing the portupgrade port, you also get the pkg_deinstall command, which is a nice neat wrapper for pkg_delete. I recommend using pkg_deinstall, it's much easier to use when it comes time to remove a package that several other packages depend on. One last note on package management, if portupgrade ever tells you that you need to manually run "pkgdb -F", it is safe to delete what are known as "Stale Dependencies". They are simply pointers to packages that are either gone, or updated and the database hasn't been updated to reflect the changes. Upgrading with "make buildworld" One of the best things about FreeBSD is the way that "FreeBSD" itself is a defined set of utilities, and when FreeBSD is updated, so are those included utilities. The most common way of upgrading an existing FreeBSD installation is to with the "make buildworld" and "make installworld" commands.
You can get a copy of the source sup file in /usr/share/examples/cvsup/stable-cvsup. Be sure to change the host name of the server. Now all you have to do it type "cvsup stable-cvsup", and you get the latest and greatest copy of the stable source code for Freebsd-4.x. Once again the time it takes for this complete depends on the speed of your Internet connection and the time elapsed since you last cvsup'd the source tree. The ports tree is universal no matter what version of FreeBSD your using, so the ports tree you cvsup on a -STABLE system is the same as what you get if you cvsup on -CURRENT. The source tree however is made up of many versions. There are the -STABLE and the -CURRENT trees. The -CURRENT tree is currently in testing (think beta) and should not be used on production systems. The -STABLE tree is made up of the "stable" source code. The versions of FreeBSD that is available as ISO's are simply periodic snapshots of the -STABLE tree. You should track the -STABLE tree for your production servers, as the -STABLE tree is updated with bug fixes and security patches.
After the cvsup finishes, cd into the /usr/obj directory and make sure that it is empty. When you compile the source code for -STABLE or -CURRENT the temporary files go into the /usr/obj directory. If there are files in this directory it is possible that they could conflict with the newer files that we are trying to compile. It's just best to empty that directory before we start. Now cd into the /usr/src directory and type "make buildworld". The compiles the new code, but does not install it. After that finishes we have to boot into single user mode. Reboot the machine, before you get the message telling you to press Enter to boot /kernel, hit any key. That should drop you at a prompt, type "boot -s /kernel". In FreeBSD the OS's kernel is /kernel, what the above command does is tell the loader to boot /kernel into single user mode. After it boots into single user mode, it will ask for a path to your preferred shell, or use sh by default. After you set the shell, type "fsck -p" which checks the filesystem for inconsistencies. Next type "mount -u /", this changes status of the / partition from read-only to read-write. Now type "mount -a" – this mounts all of the filesystems in the /etc/fstab file that do NOT have the "noauto" option. Finally cd into the /usr/src directory and type "make installworld". This step actually installs the new files from the /usr/obj directory. After it finishes hit the "Ctrl-D" combo to boot the machine into multi-user mode.