Fixing source-code bugs using MacPorts facilities.

Ian Wadham at
Sat Jul 25 04:01:57 UTC 2020

Hi guys,

I have just been fixing a bug in the code for KPat, the KDE 4 Patience (Solitaire) game, using MacPorts facilities to submit, compile, build and install patches, including source code for fixing and testing bugs. I have followed the guidance in Chapter 4 of the MacPorts Guide and especially sections 4.5 Patch Files and 4.6 Local Portfile Repositories.

This has worked very well and I have had a patch committed upstream to the kpat master, but I am sure my workflow has been sub-optimal and I would like some suggestions for improving it before continuing on and fixing other bugs. The overall approach is workable because, although KDE Games is based on KDE 4 in MacPorts and the central KDE repositories are now about 5 years further on, the code I am interested in fixing is “game engine” code and has changed very little over that time period.

Following the Guide, I have set up the following “local port” data structure:

            portfile (editable)
                source code a.cpp (editable)
                source code a.cpp.orig (read-only)
                patch file patch-aN.cpp
                patch file patch-bM.cpp
                source code sub-directory patsolve/ (mirroring the source code structure)
                    source code b.cpp (editable, known as patsolve/b.cpp in patch files)
                    source code b.cpp.orig (read-only, known as patsolve/b.cpp.orig in patch files)

N and M are sequence numbers, which I bump every time I edit a.cpp or b.cpp and create a new version of the patch.

In MacPorts KPat is at version kpat @4.14.3_3. I began by bumping the revision line in my local portfile from 3 to 4. Then I uninstalled kpat and re-installed it using port -sk to get and keep the source. Then I copied the source code files kpat/a.cpp and patsolve/b.cpp, twice each, to create local files a.cpp, a.cpp.orig, patsolve/b.cpp and patsolve/b.cpp.orig.

My workflow was basically edit, patch, build, test, as follows:

Edit a source file
Generate a new patch file with a new number N or M
Edit kpat/portfile to record the new N or M in the patch-file name
Run portindex in directory /kdedev/ports
Change to /kdedev/ports/kde/kpat
Run sudo port uninstall kpat
Run sudo -sk install kpat
If any compile or link errors, go back to the edit step
Test kpat, either by running it from the dock or from the command line

To run from the command line and get stderr output, I would do cd . in directory /Applications/MacPorts/KDE4/ to make the kpat executable visible in the Term window I dedicated to testing.

I know MacPorts developers have smarter ways of doing all this, so I hope someone can help.

Ian W.

P.S. My patches should be of value in fixing bugs in the MacPorts’ KDE 4 version of KPat, which is no longer supported upstream.

More information about the macports-users mailing list