> 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/port/di-8-zhang-gao-ji-pkgplist-shi-jian/8.3.-pei-zhi-wen-jian.md).

# 8.3.配置文件

如果 Port 将配置文件安装到 **PREFIX/etc**（或其他目录），**不要**在 **pkg-plist** 中列出这些文件。这样做会导致 `pkg delete` 删除用户精心编辑过的文件，而重新安装时也会将其覆盖。

正确做法是安装带有 **filename.sample** 扩展名的示例文件。`@sample` 宏可以自动完成这一过程，详见 [用关键词扩展软件包列表](https://docs.freebsd.org/en/books/porters-handbook/plist/#plist-keywords-sample)。对于每个示例文件，在 **pkg-plist** 中添加如下行：

```sh
@sample etc/orbit.conf.sample
```

如果确有充分理由不默认安装一个可用的配置文件，仅在 **pkg-plist** 中列出示例文件名，不添加 `@sample` 前缀，并添加 [消息提示](https://docs.freebsd.org/en/books/porters-handbook/pkg-files/#porting-message)，告知用户必须手动复制并编辑该文件以使软件正常工作。

> **技巧**
>
> 如果 Port 的配置文件安装在 **${PREFIX}/etc** 的某个子目录中，应使用 `ETCDIR`。该变量默认值为 `${PREFIX}/etc/${PORTNAME}`，如果 Port 惯例上使用其他目录，可以在 Port 的 **Makefile** 中覆盖此默认值。在 **pkg-plist** 中用 `%%ETCDIR%%` 来代替路径。

> **注意**
>
> 示例配置文件应始终使用 **.sample** 后缀。如果出于历史原因无法使用标准后缀，或示例文件位于其他目录中，可以使用如下格式：
>
> ```sh
> @sample etc/orbit.conf-dist etc/orbit.conf
> ```
>
> 或
>
> ```sh
> @sample %%EXAMPLESDIR%%/orbit.conf etc/orbit.conf
> ```
>
> 格式为 `@sample _sample-file actual-config-file_`。


---

# 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 dynamically by asking a question.

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

```
GET https://book.bsdcn.org/port/di-8-zhang-gao-ji-pkgplist-shi-jian/8.3.-pei-zhi-wen-jian.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
