> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/porters-handbook/di-8-zhang-gao-ji-pkgplist-shi-jian/8.2.-kong-mu-lu.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
