# 8.2.空目录

## 8.2.1. 清理空目录

在卸载 Port 时，必须删除它所创建的空目录。大多数目录会被 [pkg(8)](https://man.freebsd.org/cgi/man.cgi?query=pkg\&sektion=8\&format=html) 自动删除，但对于在 **${PREFIX}** 之外创建的目录或本身为空的目录，则需要额外处理。通常通过为这些目录添加 `@dir` 行来实现。删除时必须先删除子目录，再删除父目录。

```sh
[...]
@dir /var/games/oneko/saved-games
@dir /var/games/oneko
```

## 8.2.2. 创建空目录

Port 安装过程中创建的空目录需要特别注意。在生成软件包时，这些目录必须存在。如果 Port 的代码没有自动创建这些目录，就需要在 **Makefile** 中显式创建：

```makefile
post-install:
	${MKDIR} ${STAGEDIR}${PREFIX}/some/directory
```

像对待其他条目一样将该目录添加进 **pkg-plist**：

```sh
@dir some/directory
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://porters-handbook.bsdcn.org/di-8-zhang-gao-ji-pkgplist-shi-jian/8.2.-kong-mu-lu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
