FreeBSD Update All Installed Ports / Applications

by on August 26, 2009 · 6 comments· LAST UPDATED June 11, 2013

in , ,

It is recommended that to keep FreeBSD systems up to date with the latest application security patches installed via ports collection. The yum command line tool is used to install and update software packages under CentOS / RHEL / Fedora Linux. However, I've tons of apps installed under FreeBSD. How do I upgrade all packages under FreeBSD?

FreeBSD comes with various tools to to install and update software packages. The portmaster command line tool is used to install and update software packages. There are four steps here. Most of the actions listed in this FAQ are written with the assumption that they will be executed by the root user running the csh or bash shell.

Step # 1: Update FreeBSD Ports Tree

Type the following command. Only run this command to initialize your portsnap-maintained ports tree for the first time:
# portsnap fetch extract
Install portmaster to manage your ports without external databases or languages:
# cd /usr/ports/ports-mgmt/portmaster
# make install clean

Step # 2: List All Outdated Packages FreeBSD Ports Tree

Type the following command:
# pkg_version -l '<'
Sample Output:

apache                              <
libiconv                            <
libxml2                             <
mod_security                        <
mysql-client                        <
p5-Storable                         <
portmaster                          <
postfix                             <
spawn-fcgi                          <

Step # 3: Read /usr/ports/UPDATING File

Open /usr/ports/UPDATING file using a text editor and read information regarding your applications. This file describes various issues and additional steps users may encounter and need to perform when updating a port, including such things as file format changes, changes in locations of configuration files, or other such incompatibilities with previous versions.
# vi /usr/ports/UPDATING

Step # 4: Upgrade All Packages / Ports / Apps

Type the following command:
# portmaster -Da
Sample Outputs:

===>>> Starting check of installed ports for available updates
===>>> Checking ports for recursive 'make config'
	===>>> The devel/libltdl15 port moved to devel/libltdl22
	===>>> Reason: Update to libltdl22
===>>> Launching child to update libltdl-1.5.26
	===>>> The devel/libltdl15 port moved to devel/libltdl22
	===>>> Reason: Update to libltdl22
......
......output terminated...
....

How Do I Repeat These Steps Again?

Simply use the following command sequence (note: portsnap update option):
# portsnap fetch update
# pkg_version -l '<'
# vi /usr/ports/UPDATING
# portmaster -Da

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 6 comments… read them below or add one }

1 Woolfer August 27, 2009 at 7:58 am

1. portsnap fetch && portsnap update
2. portupgrade -rR *

Reply

2 Shoaibi August 27, 2009 at 10:31 am

i use:
portsnap fetch && portsnap update && portaudit -F && portupgrade -aR

all in one go :P

Good post btw, thanks.

Reply

3 Valqk August 27, 2009 at 12:38 pm

Wonderful app portmaster is. :-)
I use it with with -ag switches bcause I have a pkg server :)
portupgrade sux (according to me :)

Reply

4 nixCraft August 27, 2009 at 1:14 pm

Can be:

portsnap fetch && portsnap update

Run as :

portsnap fetch update

portupgrade needs ruby and db. portmaster directly work, it is a small and very fast tool. pkg_version is part of base system. Reading /usr/ports/UPDATING is mandatory.

HTH

Reply

5 SIFE September 20, 2009 at 12:17 am

Salamo Alikom
how can i update single port ?

Reply

6 m May 16, 2012 at 6:11 am

it fails for me,it say that “no mirrors remaining,giving up” .
what should I do?

Reply

Leave a Comment

Tagged as: , , , , , ,

Previous Faq:

Next Faq: