How to Update Ports in FreeBSD

Normally we are writing  more  about Linux here at Unixmen. But today, I will give you some tips about the FreeBSD upgrade system and packages.

Question:

How to update ports in FreeBSD?

Answer:

Let me give you some information about my BSD system.

root@:/root # uname -a
FreeBSD 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec 4 09:23:10 UTC 2012     
root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64

Portsnap is  the best recommendation to upgrade your Ports /usr/ports and extract all new ports on /usr/ports


# portsnap fetch
Looking up portsnap.FreeBSD.org mirrors... 6 mirrors found.
Fetching public key from ec2-eu-west-1.portsnap.freebsd.org... done.
Fetching snapshot tag from ec2-eu-west-1.portsnap.freebsd.org... done.
Fetching snapshot metadata... done.
Fetching snapshot generated at Sun Apr 14 02:03:58 CEST 2013:
1709e7af6e3a645345b0cad6387bb8cd95e3aa0e90f377100% of   68 MB 2688 kBps 00m00s
Extracting snapshot... done.
Verifying snapshot integrity...

# portsnap extract

If you already have a populated /usr/ports and you are just updating, run the following command instead:


# portsnap fetch update
Applying patches... done.
Fetching 0 new ports or files... done.
Removing old files and directories... done.
Extracting new files:
/usr/ports/net-mgmt/nagios-check_tftp/
Building new INDEX files... done.

Now you can check which ports are outdated:


# pkg_version -v | grep need

mariadb-client-5.3.8                <   needs updating (port has 5.3.12)
root@:/usr/ports/ #

Next, install portupgrade utility to easily upgrade installed ports:


root@:/usr/ports/ports-mgmt/portupgrade # make install clean
===> Building/installing dialog4ports as it is required for the config dialog
===>  Cleaning for dialog4ports-0.1.3
=> dialog4ports-0.1.3.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch http://m1cro.tk/dialog4ports/dialog4ports-0.1.3.tar.gz
dialog4ports-0.1.3.tar.gz                     100% of 9743  B   10 kBps
===> Fetching all distfiles required by dialog4ports-0.1.3 for building
===>  Extracting for dialog4ports-0.1.3
=> SHA256 Checksum OK for dialog4ports-0.1.3.tar.gz.

Scan the list of installed ports and fixes:


# pkgdb -F

If you want to upgrade all outdated ports, then run:


# portupgrade -a

If you want to upgrade only certain applications, use portupgrade pkgname. Include the -R flag.


# portupgrade -R apache

After the installation software, now you have to clean up the temporary work directories using the make clean command:


# portsclean -C