1. Introduction
2. Installing MacPorts
2.1. Install Xcode
2.2. Install MacPorts
2.3. Upgrade MacPorts
2.4. Uninstall MacPorts
2.5. 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. Subports
4.6. Patch Files
4.7. Local Portfile Repositories
4.8. Portfile Best Practices
4.9. 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. Subports
5.7. Tcl Extensions & Useful Tcl Commands
5.8. StartupItems
5.9. Livecheck / Distcheck
5.10. 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
6.6. Tests
7. MacPorts Project
7.1. Using Trac for Tickets
7.2. Using Git and GitHub
7.3. Contributing to MacPorts
7.4. Port Update Policies
7.5. Updating Documentation
7.6. MacPorts Membership
7.7. The PortMgr Team
8. MacPorts Guide Glossary
Glossary

4.2. Creating a Portfile

Here we list the individual Portfile components for an application that conforms to the standard configure, make, and make install steps of most open source application installs.

  1. Modeline

    This should be the first line of a Portfile. It sets the correct editing options for vim and emacs. See Port Style for more information. Its use is optional and up to the port maintainer.

    # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
  2. PortSystem line

    This statement is required for all ports.

    PortSystem          1.0
  3. Port name

    name                rrdtool
  4. Port version

    version             1.2.23
  5. Port categories

    A port may belong to more than one category, but the first (primary) category should match the directory name in the ports tree where the Portfile is to reside.

    categories          net
  6. Platform statement

    platforms           darwin
  7. Port maintainers

    A port's maintainers are the people who have agreed to take responsibility for keeping the port up-to-date. The maintainers keyword lists the maintainers' GitHub usernames or email addresses, preferably in the obfuscated form which hides them from spambots. For more, see the full explanation of the maintainers keyword in the Global Keywords section of the Portfile Reference chapter.

    maintainers         @neverpanic \
                        jdoe \
                        example.org:julesverne
  8. Port description

    description         Round Robin Database
  9. Port long_description

    long_description    RRDtool is a system to store and display time-series \
                        data
  10. A port's application homepage

    homepage            https://people.ee.ethz.ch/~oetiker/webtools/rrdtool/
  11. A port's download URLs

    master_sites        https://oss.oetiker.ch/rrdtool/pub/ \
                        ftp://ftp.pucpr.br/rrdtool/
  12. Port checksums

    The checksums specified in a Portfile are checked with the fetched tarball for security. For the best security, use rmd160 and sha256 checksum types. Checksums should also include the target file's size.

    checksums               rmd160  7bbfce4fecc2a8e1ca081169e70c1a298ab1b75a \
                            sha256  2829fcb7393bac85925090b286b1f9c3cd3fbbf8e7f35796ef4131322509aa53 \
                            size    1061530

    To find the correct checksums for a port's distribution file, follow one of these examples:

    %% openssl dgst -rmd160 rrdtool-1.2.23.tar.gz
    %% openssl dgst -sha256 rrdtool-1.2.23.tar.gz
    RIPEMD160( ... rrdtool-1.2.23.tar.gz)= 7bbfce4fecc2a8e1ca081169e70c1a298ab1b75a
    
    SHA256( ... rrdtool-1.2.23.tar.gz)= 2829fcb7393bac85925090b286b1f9c3cd3fbbf8e7f35796ef4131322509aa53

    or update the version in the Portfile:

    %% sudo port edit rrdtool

    and run:

    %% port -v checksum rrdtool
    --->  Fetching distfiles for rrdtool
    --->  Verifying checksums for rrdtool
    --->  Checksumming rrdtool-1.2.23.tar.gz
    Error: Checksum (rmd160) mismatch for rrdtool-1.2.23.tar.gz
    Portfile checksum: rrdtool-1.2.23.tar.gz rmd160 ...WRONGCHECKSUM...
    Distfile checksum: rrdtool-1.2.23.tar.gz rmd160 7bbfce4fecc2a8e1ca081169e70c1a298ab1b75a
    Error: Checksum (sha256) mismatch for rrdtool-1.2.23.tar.gz
    Portfile checksum: rrdtool-1.2.23.tar.gz sha256 ...WRONGCHECKSUM...
    Distfile checksum: rrdtool-1.2.23.tar.gz sha256 2829fcb7393bac85925090b286b1f9c3cd3fbbf8e7f35796ef4131322509aa53
    The correct checksum line may be:
    checksums           rmd160  7bbfce4fecc2a8e1ca081169e70c1a298ab1b75a \
                        sha256  2829fcb7393bac85925090b286b1f9c3cd3fbbf8e7f35796ef4131322509aa5
    Error: Failed to checksum rrdtool: Unable to verify file checksums
    Error: See ...SOMEPATH.../rrdtool/main.log for details.
    Error: Follow https://guide.macports.org/#project.tickets to report a bug.
    Error: Processing of port rrdtool failed
  13. Port dependencies

    A port's dependencies are ports that must be installed before another port is installed.

    depends_lib         port:perl5.8 \
                        port:tcl \
                        port:zlib
  14. Port configure arguments (optional)

    configure.args      --enable-perl-site-install \
                        --mandir=${prefix}/share/man