nfpm icon indicating copy to clipboard operation
nfpm copied to clipboard

Handle packaging formats with non-distinct file extensions

Open Elara6331 opened this issue 1 year ago • 5 comments

Is your feature request related to a problem? Please describe.

When implementing #543, I imported it into a local clone of goreleaser in order to test it. I noticed that it created a file with the .archlinux extension. The issue is that the packager was registered as "archlinux", which I did because Arch Linux doesn't have a distinct package extension, and just uses .tar.zst, which is the extension for any TAR file compressed with Zstandard.

Describe the solution you'd like

I think the best solution would be to add a new interface that looks something like this:

type PackagerWithExtension interface {
	Packager
	ConventionalExtension() string // Returns an extension like .rpm or .pkg.tar.zst
}

This way, a breaking change is avoided, while providing a type-safe way to check the extension. To check the extension, you'd do something like

if packager, ok := packager.(nfpm.PackagerWithExtension); ok {
	ext := packager.ConventionalExtension()
	// do something with ext
}

Describe alternatives you've considered

The ConventionalExtension() method could be added directly to the Packager interface, but that would be a breaking change. Also, an extension argument could be added to RegisterPackager(), but that would be a breaking change as well.

Search

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

Code of Conduct

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

Additional context

No response

Elara6331 avatar Sep 12 '22 23:09 Elara6331

I like this, as long as @caarlos0 is good with this I say add it as part of #543

djgilcrease avatar Sep 13 '22 05:09 djgilcrease

I like it too, thanks for the suggestion, and feel free to do it as part of #543 if you feel like it 🙏

caarlos0 avatar Sep 13 '22 12:09 caarlos0

Should I add the ConventionalExtension() method to all packagers as part of my PR or just Arch?

Elara6331 avatar Sep 13 '22 17:09 Elara6331

I would say probably all @Arsen6331

caarlos0 avatar Sep 13 '22 17:09 caarlos0

Done

Elara6331 avatar Sep 13 '22 18:09 Elara6331