To create and test Portfiles that are not yet published in the MacPorts ports tree, you may create a local Portfile repository as shown.
Replace the hypothetical user julesverne
with your username in the example below.
Open sources.conf
in a text editor. For example, to open it into TextEdit:
%% open -e ${prefix}/etc/macports/sources.conf
Insert a URL pointing to your local repository location before the rsync URL as shown.
file:///Users/julesverne/ports rsync://rsync.macports.org/macports/release/tarballs/ports.tar [default]
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.
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