Managing Your Ports

CVSup - Updating your Ports:

Ports are the applications that you have available for installation. These may include: apache, mySQL, PHP, Perl, etc. CVSup will download the latest version of the ports so you will always be kept up to date.

Step 1: Install CVSup

  1. Install cvsup-without-gui from the ports collection
    	# cd /usr/ports/net/cvsup-without-gui
    	# make all install clean

Step 2: Configuring CVSup

  1. Copy sample file to appropriate location
    	# mkdir /usr/local/etc/cvsup
    	# cp /usr/share/examples/cvsup/ports-supfile /usr/local/etc/cvsup
  2. Edit the file with the appropriate settings
    	# vi /usr/local/etc/cvsup/ports-supfile
    	: Change the "*default host=" to a host near you
    	: Change the "*default base=" to a location to store the ports info
    	: If you only wish to update certain ports make sure to comment out ports-all and uncomment ports-base

    Note: You can find a list of default hosts at:

    Note: As mentioned above you can specifically choose which ports you do not wish to update by commenting out the ports-all option and uncomment ports-base and any other ports you wish to keep updated.

  3. Now you will want to run the "rehash" command so you can run the program.
    	# rehash

Step 3: Run CVSup

  1. If you are behind a firewall try this
    	# cvsup -P m /usr/local/etc/cvsup/ports-supfile
  2. Otherwise try this
    	# cvsup /usr/local/etc/cvsup/ports-supfile
  3. You may want to install a cronjob for this to run once a month or whatever period is appropriate.

    Note: Every five minutes or even every day is not appropriate
    Note: See information on creating cronjobs and vi if you don't know what to do

    	# crontab -e
    	0 0 1 * * /usr/local/bin/cvsup /usr/local/etc/cvsup/ports-supfile > /dev/null
    	Then you can press :q to install the new job

Updating Installed Ports - Portupgrade:

Managing your ports and keeping them updated with the latest releases is one of the most important tasks you can perform. By keeping up with the most recent stable releases of the ports you ensure you are using the most reliable and secure ports available. Portupgrade is a nice little package that will assist you in managing all of your ports and keeping the up to date. The first step to perform is the installation of the port itself.

# cd /usr/ports/sysutils/portupgrade
# make all install clean
# rehash

Now that we have installed the port and added it to the current path we can run it. There are a few tasks that we should perform first before running portupgrade.

# pkgdb -F

This command will gather the information about currently installed ports and there dependencies. You may be asked several questions about what you would like to do or how it should handle various port information. If you are in doubt you can always skip it and run the command again later. The next think you should do is CVSUP your ports if you haven't already. From now on always make sure you run the 'portsdb -Uu' command after you cvsup your ports. Let's run this command now.

# portsdb -Uu

Run 'portversion | grep "<" ' to find out which ports are out of date Run 'portupgrade -PR [port_name listed in d] ' to upgrade a single port and all of it's dependencies or run 'portupgrade -aPR' to automatically update all out of date ports Look at the /usr/ports/sysutils/portupgrade/pkg-desc for other commands like portclean, etc Cleaning and Auto-Updating Ports:

Now that you can keep the ports tree updated and know how to check the current version of your installed ports there are a couple more things to do. You will want to keep your drive clean of older unused files from previous ports that are outdated and you may also want to do some auto-updating on ports that are out of date.

The easiest way to maintain your installed ports is by using portversion. Portversion has several command that are helpful. For example, if you wanted to clean up the files that are no longer needed you may wish to run:
portsclean -C -D -L -P

You may want to consider modifying the pkgtools.conf file to customize portsclean. The file you wish to edit should be in /usr/local/etc/pkgtools.conf.

If you are going to be installing new ports or wish to simply update your out of date ports you may wish to use the portupgrade command. Portupgrade is a tool that allows you to upgrade installed packages or install new ones using either ports or packages. There are several switches that may work best for you. Please read the man pages for a detailed description of the switches. In this tutorial we are going to cover only the most commonly used switches.

To install a new port using portupgrade simply type in the following command:
portupgrade -N portname

If you wish to update the ports that are out of date automatically type in the following:
portupgrade -ra

If you only wish to update a specific port and all ports required by the specified port:
portupgrade -R portname

Make sure you read through the man pages for portupgrade as there are many options that you may find useful. You may occasionaly run into problems but overall this feature is what finally makes ports a wonderful tool.