When the FreeBSD project switched to git for the ports development I had several days the problem that portsnap didn’t allow me to update the ports tree. I searched for a solution to get an up-to-date portstree.
One solution would be to use the git repository directly.

How I used portsnap to update the ports tree regularly

Every night at 3:00 I ran a cronjob which fetches the current snapshot of the port tree.

# /etc/crontab - root's crontab for FreeBSD
#
# [other default stuff]
#
# run update of the ports at 3 in the night
0       3       *       *       *       root    /usr/sbin/portsnap cron

What was getting on my nerves every time was that I had to run portsnap update every time to force an update of the ports tree. After that I could check if there are updates of my installed applications. Of course I could also automate this, but I didn’t want to do that.

How I update the ports tree now

Currenlty I’ll update the ports tree with git and use the ports repository directly. This also has the advantage that the local ports are more up-to-date than the ports snaptshots which were downloaded by portsnap.
Another advantage is that I do not have to install the ports tree in a separate command. Everything is right in place after the git command ran.

First you have to drop everything inside your /usr/ports directory. Simply run rm -rf /usr/ports/*. After that check if there is really nothing left in the directory. If there is something left, simply delete it.

Now you have to checkout the git repository. To do that run the following command:

git clone https://git.FreeBSD.org/ports.git /usr/ports

After that you have to checkout the ports tree

git -C /usr/ports pull

To update the ports tree regularly like before with portsnap just replace the portsnap cron command in the /etc/crontab with the pull command shown below.

# /etc/crontab - root's crontab for FreeBSD
# 
# [other default stuff]
#
# run update of the ports at 3 in the night
0       3       *       *       *       root    /usr/local/bin/git -C /usr/ports pull --ff-only

After that is done, you can check if there are new versions of you installed application and install them.
Check if there is something to update:

pkg version -l "<"

Install the updates (I use portmaster):

portmaster -ad

Or if you do not care on backups of the installed ports:

portmaster -Bad
Categories: FreeBSD