Skip to content

type: doc excludes files from non-RPM packages instead of treating them as normal files #1037

@janderssonse

Description

@janderssonse

What happened?

Files with type: doc (and other RPM-specific types like license, readme) are completely
excluded from deb and apk packages, contradicting the documentation which states they
should be "ignored" (treated as normal files) by other packagers.

Documentation vs Actual Behavior

Documentation states (https://pkg.go.dev/github.com/goreleaser/nfpm/v2/files,
https://nfpm.goreleaser.com/docs/configuration/):

TypeRPMDoc is "the type of an RPM doc file which is ignored by other packagers."

"For packagers other than RPM, [...] the remaining RPM-specific types are the same as '',
a normal file."

Actual behavior in files/files.go (isRelevantForPackager function):

if packager != "rpm" &&
(content.Type == TypeRPMDoc || content.Type == TypeRPMLicence ||
content.Type == TypeRPMLicense || content.Type == TypeRPMReadme ||
content.Type == TypeRPMGhost) {
return false // Files are EXCLUDED, not treated as normal files
}

Users who want to mark documentation files with %doc in RPM while still including them in
deb/apk packages cannot do so. The workaround is to not use type: doc at all, which
means losing the %doc functionality in RPM.

How can we reproduce this?

nfpm.yaml:
contents:
- src: ./README.md
dst: /usr/share/doc/mypackage/README.md
type: doc
file_info:
mode: 0644

Expected behavior:

  • RPM: File included with %doc marking
  • Deb/APK: File included as a normal file (type ignored)

Actual behavior:

  • RPM: File included with %doc marking ✓
  • Deb/APK: File is completely missing from package ✗

nfpm version

latest

Search

  • I did search for other open and closed issues before opening this.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

In isRelevantForPackager, instead of returning false for RPM-specific types on non-RPM
packagers, the types should be normalized to regular files:

// Option 1: Don't filter, let them fall through as regular files
// Remove the filtering block entirely, or:

// Option 2: Normalize the type instead of excluding
if packager != "rpm" {
switch content.Type {
case TypeRPMDoc, TypeRPMLicence, TypeRPMLicense, TypeRPMReadme:
content.Type = TypeFile // Treat as normal file
case TypeRPMGhost:
return false // Ghost files should still be excluded
}
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions