-
Open sources.conf in a text editor. For example, to open it into TextEdit:
open -e ${prefix}/etc/macports/sources.conf prefix = /opt/local
-
Insert a URL pointing to your local repository location before the rsync URL as shown.
file:///Users/Ricky/ports rsync://rsync.macports.org/release/ports [default]
Note
The file URL should always appear before the rsync URL so that local Portfiles
can be tested that are duplicated in the MacPorts tree, because port will always
operate on the first Portfile it encounters.
- Place the Portfiles you create inside a directory whose name matches the port, which should in turn be placed inside a directory that reflects the port's primary category (the first category entry in the Portfile). For example, to create the directory for a hypothetical port “bestevergame” and to begin editing its Portfile in TextEdit, you can use these commands:
mkdir -p ~/ports/games/bestevergame
cd ~/ports/games/bestevergame
touch Portfile
open -e Portfile
See other sections in the Guide for help writing Portfiles. If you've already written the Portfile elsewhere, you can instead copy the Portfile into this directory.
-
If your Portfile needs to apply any patches to the port's source files, create a files directory and place the patchfiles in it, and reference the patchfiles in your Portfile, as explained in Creating Source Code Patches.
-
After you create or update your Portfile, use portindex in the local repository's directory to create or update the index of the ports in your local repository.
cd ~/ports
portindex
Creating software index in /Users/julesverne/ports
Adding port games/bestevergame
Total number of ports parsed: 1
Ports successfully parsed: 1
Ports failed: 0
Once the local port is added to the PortIndex, it becomes available for searching or installation as with any other Portfile in the MacPorts tree:
%% port search bestever
bestevergame @1.1 (games)
The Best Ever Game
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):
mkdir -p ~/ports
Create the port's category directory (using port "arb" as an example):
PORT_CATEGORY=`port dir arb | awk -F\/ '{ print $(NF-1) }'`
mkdir ~/ports/$PORT_CATEGORY
cd ~/ports/$PORT_CATEGORY
cp -r `port dir arb` .
mv arb arb-devel
# edit arb-devel/Portfile and replace "name arb" with "name arb-devel"
cd arb-devel
port lint # to check for problems
Add this line before the 'rsync://.......' line in /opt/local/etc/macports/sources.conf, at the end of the file:
file:///Users/Ricky/ports
Then run this command:
cd ~/ports && portindex
port patch arb-devel
cd `port work arb-devel`
cp Makefile Makefile.orig
vi Makefile
- make changes, compile it, test it *
See http://guide.macports.org/#development.patches.source
diff -u Makefile.orig Makefile > `port dir arb-devel`/files/patch-ARB-makefile2.diff
port edit arb-devel # (add the patch-ARB-makefile2.diff file to the list of patches)
port clean arb-devel
port build arb-devel
port -s install arb-devel