Fixing source-code bugs using MacPorts facilities.

Ken Cunningham ken.cunningham.webuse at gmail.com
Sat Jul 25 17:31:14 UTC 2020


Here is my process (courtesy of advice from many others on this list including Chris and Michael and others). And this is not yet ideal, as no doubt it could be further improved. This is for anything beyond trivial one-tweak patches, by the way — I might not do this for a trivial source fix.


Set up your local ports repository like you have, copy the current portfile directory into it, etc.

Go to the port’s directory in the new repo, and 

sudo port -v build

when it errors, open a new terminal window, navigate to the same directory you’re in now, and then

cd work
sudo chmod -R a+rw .

cd into the source directory, whatever it’s called, then set it up as a temporary git repo:

git init
git add .
git commit -m “init” > /dev/null

now you’re ready to do your work.

edit your source files as needed.


You now have two terminal windows open. One is the port directory, one is the source directory.

In the port directory, try your build again:

sudo port -v build

if you get errors, in your source directory, edit the files, then rebuild again. Keep going until you get it to build.

Now you have changes in your new source git tree to save, so save those into a diff file that you can use later:

git diff —no-prefix > ~/patches-for-my-fixed-port.diff

then see if your port will destroot, and then install.

sudo port -v destroot

sudo port -v -k install

(note the -k — that keeps it from blowing out your source directory if it succeeds).

If all is well, you’re close to done. from your port directory

sudo port clean
sudo port uninstall THEPORT

cd files
mv  ~/patches-for-my-fixed-port.diff .
cd ..
bbedit Portfile

add your new patch

patchfiles-append  patches-for-my-fixed-port.diff


and then try your build — hopefully it goes right through to installing, and all your patches worked.

You’re done. Open your PR, have a latte, wait for someone to tell you how wonderful you are (yeah, right!).

Ken




More information about the macports-users mailing list