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. You need to delete subdirectories before you can delete parent directories.

 :
lib/X11/oneko/pixmaps/cat.xpm
lib/X11/oneko/sounds/cat.au
 :
@dirrm lib/X11/oneko/pixmaps
@dirrm lib/X11/oneko/sounds
@dirrm lib/X11/oneko

However, sometimes @dirrm will give you errors because other ports share the same directory. You can 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 will not get created when installing the package, because packages only store the files, and both pkg add and pkg install creates directories for them as needed. To make sure the empty directory is created when installing the package, add this line to pkg-plist above the corresponding @dirrm line:

@exec mkdir -p %D/share/foo/templates

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