% diff -u something.orig something > something.diff
Chapter 11. Upgrading a Port
Table of Contents
When a port is not the most recent version available from the authors, update the local working copy of /usr/ports. The port might have already been updated to the new version.
When working with more than a few ports, it will probably be easier to use Git to keep the whole ports collection up-to-date, as described in the Handbook. This will have the added benefit of tracking all the port’s dependencies.
The next step is to see if there is an update already pending.
To do this, there are two options.
There is a searchable interface to the FreeBSD Problem Report (PR) or bug database.
Ports & Packages in the
Product multiple select menu, and enter the name of the port in the
If there is no pending PR, the next step is to send an email to the port’s maintainer, as shown by
That person may already be working on an upgrade, or have a reason to not upgrade the port right now (because of, for example, stability problems of the new version), and there is no need to duplicate their work.
Note that unmaintained ports are listed with a maintainer of
ports@FreeBSD.org, which is just the general ports mailing list, so sending mail there probably will not help in this case.
If the maintainer asks you to do the upgrade or there is no maintainer, then help out FreeBSD by preparing the update! Please do this by using the diff(1) command in the base system.
To create a suitable
diff for a single patch, copy the file that needs patching to something.orig, save the changes to something and then create the patch:
Otherwise, either use the
git diff method (Using Git to Make Patches) or copy the contents of the port to an entire different directory and use the result of the recursive diff(1) output of the new and old ports directories (for example, if the modified port directory is called superedit and the original is in our tree as superedit.bak, then save the result of
diff -ruN superedit.bak superedit).
Either unified or context diff is fine, but port committers generally prefer unified diffs.
Note the use of the
-N option-this is the accepted way to force diff to properly deal with the case of new files being added or old files being deleted.
Before sending us the diff, please examine the output to make sure all the changes make sense.
(In particular, make sure to first clean out the work directories with
If some files have been added, copied, moved, or removed, add this information to the problem report so that the committer picking up the patch will know what git(1) commands to run.
To simplify common operations with patch files, use
make makepatch as described in Patching.
Other tools exists, like /usr/ports/Tools/scripts/patchtool.py.
Before using it, please read /usr/ports/Tools/scripts/README.patchtool.
If the port is unmaintained, and you are actively using it, please consider volunteering to become its maintainer. FreeBSD has over 4000 ports without maintainers, and this is an area where more volunteers are always needed. (For a detailed description of the responsibilities of maintainers, refer to the section in the Developer’s Handbook.)
To submit the diff, use the bug submit form (product
Ports & Packages, component
Always include the category with the port name, followed by colon, and brief descripton of the issue.
category/portname: add FOO option;
category/portname: Update to X.Y.
Please mention any added or deleted files in the message, as they have to be explicitly specified to git(1) when doing a commit.
Do not compress or encode the diff.
Before submitting the bug, review the Writing the problem report section in the Problem Reports article. It contains far more information about how to write useful problem reports.
If the upgrade is motivated by security concerns or a serious fault in the currently committed port,
please notify the Ports Management Team <portmgr@FreeBSD.org> to request immediate rebuilding and redistribution of the port’s package.
Unsuspecting users of
Please use diff(1) or
Now that all of that is done, read about how to keep up-to-date in Keeping Up.
11.1. Using Git to Make Patches
When possible, please submit a git(1) patch or diff. They are easier to handle than diffs between "new and old" directories. It is easier to see what has changed, and to update the diff if something was modified in the Ports Collection since the work on it began, or if the committer asks for something to be fixed. Also, a patch generated with git-format-patch(1) or git-diff(1) can be easily applied with git-am(1) or git-apply(1) and will save some time for the committer. Finally, the git patch generated by git-format-patch(1) includes your author information and commit messages. These will be recorded in the log of the repository and this is the recommended way to submit your changes.
% git clone https://git.FreeBSD.org/ports.git ~/my_wrkdir (1) (2) % cd ~/my_wrkdir
|1||This can be anywhere, of course. Building ports is not limited to within /usr/ports/.|
|2||git.FreeBSD.org is the FreeBSD public Git server. See FreeBSD Git Repository URL Table for more information.|
While in the port directory, make any changes that are needed.
If adding, moving, or removing a file, use
git to track these changes:
% git add new_file % git mv old_name new_name % git rm deleted_file
Before making the patch, fetch the latest repository and rebase the changes on top of it. Watch and follow the output carefully. If any of the files failed to rebase, it means that the upstream files changed while you were editing the same file, and the conflicts need to be resolved manually.
% git fetch origin main % git rebase origin/main
Check the changes staged for the patch:
% git status % git diff --staged
The last step is to make an unified diff or patch of the changes:
To generate a patch with git-format-patch(1):
% git checkout -b my_branch % git commit % git format-patch main
This will generate a patch named like
This is the preferred way as it would include author identity,
and it is also easier when you are making a series of changes that
are not meant to be squashed together.
Alternatively, to generate an unified diff with git-diff(1):
% git diff --staged > ../`make -VPKGNAME`.diff
This will generate a diff named like
foo is replaced with the first line of the commit message, i.e., the subject of the commit message.
After patch has been created, you can switch to the main branch for starting other developments.
% git checkout main
Once the patch is accepted and merged, you can delete the local development branch if you want:
% git branch -D my_branch
If files have been added, moved, or removed, include the git(1)
Send the patch following the problem report submission guidelines.
11.2. UPDATING and MOVED
If upgrading the port requires special steps like changing configuration files or running a specific program, it must be documented in this file. The format of an entry in this file is:
YYYYMMDD: AFFECTS: users of portcategory/portname AUTHOR: Your name <Your email address> Special instructions
When including exact portmaster, portupgrade, and/or pkg instructions, please make sure to get the shell escaping right. For example, do not use:
As shown, the command will only work with bourne shells. Instead, use the form shown below, which will work with both bourne shell and c-shell:
It is recommended that the AFFECTS line contains a glob matching all the ports affected by the entry so that automated tools can parse it as easily as possible.
If an update concerns all the existing BIND 9 versions the
This file is used to list moved or removed ports.
Each line in the file is made up of the name of the port, where the port was moved, when, and why.
If the port was removed, the section detailing where it was moved can be left blank.
Each section must be separated by the
| (pipe) character, like so:
old name|new name (blank for deleted)|date of move|reason
The date must be entered in the form
New entries are added to the end of the list to keep it in chronological order, with the oldest entry at the top of the list.
If a port was removed but has since been restored, delete the line in this file that states that it was removed.
If a port was renamed and then renamed back to its original name, add a new one with the intermediate name to the old name, and remove the old entry as to not create a loop.
Any changes must be validated with
If using a ports directory other than /usr/ports, use:
Last modified on: April 21, 2022 by Danilo G. Baio