wiki:howto/PatchLocal

Version 3 (modified by macports.org@…, 12 years ago) (diff)

Incorporated changes from Rainer Müller

<- Back to the HOWTO section

How to Patch a Port on Your System

  • Audience: People who want to change the code of an existing port
  • Requires: MacPorts >= 2.1.2?

Introduction

If you've ever found a port that doesn't work, then found a patch for it with Google, the next step is to apply the patch to the source code, then compile, test, and install the new version of the port so you can use it and get on with your work. This HOWTO will show you how to do that. In this example, I'll be using the 'arb' program as an example.

Installation

Step 1: Set up a local repository

If you want to make changes that stick and won't be overwritten by accident, you need to set up a local repository, described in full here: http://guide.macports.org/#development.local-repositories

Do this to create a new Port (as root):

umask 022
mkdir -p /usr/local/ports/
cd /usr/local/ports
cp -r `port dir arb` .
mv arb arb-devel

Add this line before the 'rsync://.......' line in /opt/local/etc/macports/sources.conf, at the end of the file:

file:///usr/local/ports

Then run this command:

portindex   # Not working for me...?

Step 2: Get your port's sourcecode

port patch arb-devel
cd `port work arb-devel`

Step 3: Modify the source with your patch

cp Makefile Makefile.orig
vi Makefile
* make changes, compile it, test it *

Step 4: Make a patch

See http://guide.macports.org/#development.patches.source

diff -u Makefile.orig Makefile > /usr/local/ports/arb/files/patch-ARB-makefile2.diff
port edit arb-devel     (add the patch-ARB-makefile2.diff file to the list of patches)

Step 5: Test the modified port

port clean arb-devel
port build arb-devel

Step 6: Make it real

port install arb-devel

<- Back to the HOWTO section