Using Quarterly Ports on FreeBSD

FreeBSD 10.2 and higher use mismatched repos for packages and ports. This shell script simplifies updating your ports tree from the current quarterly branch.

Note: This post and script were originally written for the SVN ports repo, but both have been updated since ports were migrated to Git.

Beginning with FreeBSD 10.2, binary packages installed using pkg are built from a quarterly code branch that only receives security and build updates after it's created. The goal is to provide a more stable software repository than the ports tree, which is constantly being updated and may even include broken ports at times. However, portsnap uses the latest code (main branch) for the ports tree. Since mixing quarterly packages with the latest ports could lead to trouble, you have to choose one of these paths:

  1. Switch pkg to install packages built from the latest code.
  2. Use Git instead of portsnap to use the quarterly branch for your local ports tree.

If you need the latest and greatest packages or prefer to live on the bleeding edge, option 1 is for you. Personally, I prefer to have the most stable system possible, so I stick with option 2. The "problem" with using Git to manage your local ports tree is that the quarterly branch changes every 3 months but not necessarily on day 1 of the new quarter. Therefore, you have to check to see what the current quarterly branch is and switch to the new branch each time it changes. I created this shell script to simplify the process:


Download this script as a file

Simply save the file to /usr/local/bin or ~/bin, make it executable using chmod +x portsfetch, and run it. You can also pass an optional parameter to specify an alternate destination path, which means portsfetch /usr/jails/basejail/usr/ports can be used to switch the ezjail ports tree to the quarterly branch.

The portsfetch script attempts to do the Right Thing for these common scenarios:

  1. If the local ports tree contains files but doesn't appear to be managed by Git, portsfetch offers to delete the files for you. If you decline, it assumes you're using portsnap and uses it to update the ports tree. Agreeing to empty the directory will switch it to be managed by Git.
  2. If the local ports tree is empty (including if it was emptied in scenario 1), portsfetch will check out a fresh copy of the current quarterly branch.
  3. If the local ports tree is already on the current quarterly branch, portsfetch updates from Git.
  4. If the local ports tree is not on the right branch, portsfetch switches it to the current quarterly branch.

Other aspects of ports management are the same when using the quarterly branch. For example, you don't need to change how you build or install from ports—just start using portsfetch instead of portsnap to update your ports tree.

This is the second most popular download on my site, so I recently added it to my freebsd-scripts project on GitHub to make it easier for others to contribute improvements. If you see something I missed or have a suggestion for improvement, please mention it in the comments below or submit a pull request!

, , , , ,
comments powered by Disqus