7.2. Empty Directories

7.2.1. Cleaning Up Empty Directories

When being de-installed, A port has to remove empty directories it created. This is usually accomplished by adding @dirrm lines for all directories that are specifically created by the port. Subdirectories must be deleted before deleting parent directories.

@dirrm lib/X11/oneko/pixmaps
@dirrm lib/X11/oneko/sounds
@dirrm lib/X11/oneko

However, sometimes @dirrm will give errors because other ports share the same directory. Use @dirrmtry to remove only empty directories without warning.

@dirrmtry share/doc/gimp

This will neither print any error messages nor cause pkg delete (see pkg-delete(8)) to exit abnormally even if ${PREFIX}/share/doc/gimp is not empty due to other ports installing some files in there.

7.2.2. Creating Empty Directories

Empty directories created during port installation need special attention. They must be present when the package is created. If they are not created by the port code, create them in the Makefile:

	@${MKDIR} ${STAGEDIR}${PREFIX}/some/directory

Add the directory to pkg-plist like any other. For example, if the directory has files created when the port is used:

@dirrmtry some/directory

All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.