3.5. Common RPM directives in the %files section of spec


The following are the RPM directives that you can use in the %files section of a spec file.

Expand
表 3.1. %files section directives
MacroDefinition

%license

The %license macro identifies the file listed as a license. RPM installs and labels this file as the license, for example, %license LICENSE.

%doc

The %doc macro identifies a file listed as a documentation file. RPM installs and labels this file as the documentation file, for example, %doc README.

重要

Documentation can be excluded during package installation, for example, to conserve disk space on images. License files might look like documentation files, but they must always be installed with the software. Therefore, you must use the %license macro instead of %doc for license files.

The %doc macro is used for documentation about the packaged software, code examples, and various accompanying items. Note that if code examples are included, you must be careful when removing executable mode from the file.

%dir

The %dir macro ensures that the path is a directory owned by the RPM package. The RPM file manifest then accurately detects which directories to clean up during the uninstall operation.

Example usage:

%dir %{_libdir}/%{name}

%config(noreplace)

The %config(noreplace) macro ensures that the file is a configuration file. This file, therefore, must not be overwritten or replaced during a package installation or update if the file has been modified from the original installation checksum. If there is a change, the file will be created with .rpmnew appended at the end of the filename upon upgrade or installation. Therefore, the pre-existing or modified file on the target system remains unchanged.

Example usage:

%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部