FreeBSD Porter's Handbook
Prev | Chapter 7 Advanced `pkg-plist` practices | Next

# 7.5 Automated package list creation

First, make sure your port is almost complete, with only `pkg-plist` missing.

Next, create a temporary directory tree into which your port can be installed, and install any dependencies.

    # mkdir /var/tmp/$(make -V PORTNAME)
    # mtree -U -f $(make -V MTREE_FILE) -d -e -p /var/tmp/$(make -V PORTNAME)
    # make depends PREFIX=/var/tmp/$(make -V PORTNAME)

Store the directory structure in a new file.

    # (cd /var/tmp/$(make -V PORTNAME) && find -d * -type d) | sort > OLD-DIRS

Create an empty `pkg-plist` file:

    # :>pkg-plist

If your port honors `PREFIX` (which it should) you can then install the port and create the package list.

    # make install PREFIX=/var/tmp/$(make -V PORTNAME)
    # (cd /var/tmp/$(make -V PORTNAME) && find -d * \! -type d) | sort > pkg-plist

You must also add any newly created directories to the packing list.

    # (cd /var/tmp/$(make -V PORTNAME) && find -d * -type d) | sort | comm -13 OLD-DIRS - | sort -r | sed -e 's#^#@dirrm #' >> pkg-plist

Finally, you need to tidy up the packing list by hand; it is not all automated. Manual pages should be listed in the port's `Makefile` under `MAN`n``, and not in the package list. User configuration files should be removed, or installed as ``filename`.sample`. The `info/dir` file should not be listed and appropriate `install-info` lines should be added as noted in the info files section. Any libraries installed by the port should be listed as specified in the shared libraries section.

Alternatively, use the `plist` script in `/usr/ports/Tools/scripts/` to build the package list automatically. The `plist` script is a Ruby script that automates most of the manual steps outlined in the previous paragraphs.

The first step is the same as above: take the first three lines, that is, `mkdir`, `mtree` and `make depends`. Then build and install the port:

    # make install PREFIX=/var/tmp/$(make -V PORTNAME)

And let `plist` create the `pkg-plist` file:

    # /usr/ports/Tools/scripts/plist -Md -m $(make -V MTREE_FILE) /var/tmp/$(make -V PORTNAME) > pkg-plist

The packing list still has to be tidied up by hand as stated above.

Another tool that might be used to create an initial `pkg-plist` is `ports-mgmt/genplist`. As with any automated tool, the resulting `pkg-plist` should be checked and manually edited as needed.

Prev | Home | Next
Dynamic vs. static package list | Up | The `pkg-`*`` files

For questions about the FreeBSD ports system, e-mail <ports@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.