1. Introduction
2. Installing MacPorts
2.1. Install X11
2.2. Install Xcode
2.3. Install MacPorts
2.4. MacPorts Upgrade
2.5. Uninstall
2.6. MacPorts and the Shell
3. Using MacPorts
3.1. The port Command
3.2. Port Variants
3.3. Common Tasks
3.4. Port Binaries
4. Portfile Development
4.1. Portfile Introduction
4.2. Creating a Portfile
4.3. Example Portfiles
4.4. Port Variants
4.5. Patch Files
4.6. Local Portfile Repositories
4.7. Portfile Best Practices
4.8. MacPorts' buildbot
5. Portfile Reference
5.1. Global Keywords
5.2. Global Variables
5.3. Port Phases
5.4. Dependencies
5.5. Variants
5.6. Tcl Extensions
5.7. StartupItems
5.8. Livecheck / Distcheck
5.9. PortGroups
6. MacPorts Internals
6.1. File Hierarchy
6.2. Configuration Files
6.3. Port Images
6.4. APIs and Libs
6.5. The MacPorts Registry
7. MacPorts Project
7.1. Using Trac for tickets
7.2. Contributing to MacPorts
7.3. Port Update Policies
7.4. MacPorts Membership
7.5. The PortMgr Team
8. MacPorts Guide Terms
Glossary
Single Page Chunked

To create and test Portfiles that are not yet committed to Subversion, you may create a local Portfile repository as shown. Replace the hypothetical user julesverne with your username in the example below.

  1. Open the sources.conf file in a text editor. For example, to open it into TextEdit:

    %% open -e ${prefix}/etc/macports/sources.conf
  2. Insert a URL pointing to your local repository location before the rsync URL as shown.

    file:///Users/julesverne/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 the port command will always operate on the first Portfile it encounters.

  3. 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.

  4. 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.

  5. After you create or update your Portfile, use the MacPorts portindex command 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