7.2. Empty directories
前一頁 | 章 7. Advanced `pkg-plist` practices | 下一頁

## 7.2. Empty directories

### 7.2.1. Cleaning up empty directories

Do make your ports remove empty directories when they are de-installed. 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(1) 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 pkg_add(1) 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

前一頁 | 上一層 | 下一頁
章 7. Advanced `pkg-plist` practices | 起始頁 | 7.3. Configuration files

本文及其他文件，可由此下載： ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/。

若有 FreeBSD 方面疑問，請先閱讀 FreeBSD 相關文件，如不能解決的話，再洽詢 <questions@FreeBSD.org>。
關於本文件的問題，請洽詢 <doc@FreeBSD.org>。