# 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 的 **Makefile** 中重定义，以遵循 Port 所采用的目录规范。在 **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: 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.3.-pei-zhi-wen-jian.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.
