Skip to content

Enable pkg_rpm and pkg_subrpm to create empty RPMs#859

Merged
aiuto merged 4 commits intobazelbuild:mainfrom
kellyma2:empty-rpm
Apr 24, 2024
Merged

Enable pkg_rpm and pkg_subrpm to create empty RPMs#859
aiuto merged 4 commits intobazelbuild:mainfrom
kellyma2:empty-rpm

Conversation

@kellyma2
Copy link
Copy Markdown
Contributor

At present we fail in two ways if we try to create empty RPMs:

  • we expect srcs to be both non-empty and will fail if it is empty and we have no spec file

  • we don't emit anything for the %files block in the RPM if there are no actual files and rpmbuild doesn't like this

This change tweaks the former condition so that srcs has to be non-None or we have to have a specfile, but will allow us to have an empty ([]) value for srcs. Additionally, it injects %defattr(-,root,root) as a reasonable default for the %files blocks so as to allow rpmbuild to be happy with what we're providing.

Fixes #711

At present we fail in two ways if we try to create empty RPMs:

- we expect srcs to be both non-empty and will fail if it is
  empty and we have no spec file

- we don't emit anything for the `%files` block in the RPM if
  there are no actual files and rpmbuild doesn't like this

This change tweaks the former condition so that srcs has to be
non-None or we have to have a specfile, but will allow us to have an
empty (`[]`) value for srcs.  Additionally, it injects
`%defattr(-,root,root)` as a reasonable default for the `%files`
blocks so as to allow rpmbuild to be happy with what we're providing.
@kellyma2 kellyma2 requested review from aiuto and cgrindel as code owners April 17, 2024 22:09
Copy link
Copy Markdown
Collaborator

@aiuto aiuto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still wonder why anyone would want an empty RPM, but I'll go with the flow on that.

@kellyma2
Copy link
Copy Markdown
Contributor Author

I still wonder why anyone would want an empty RPM, but I'll go with the flow on that.

The examples I've encountered thusfar involve having an empty / stub top level RPM with non-empty sub RPMs, although I figured it's harmless to also enable sub RPMs to do this too.

We should be safe to inject this unconditionally instead of special
casing on whether or not we have no actual files.
@aiuto aiuto merged commit 7849529 into bazelbuild:main Apr 24, 2024
@kellyma2 kellyma2 deleted the empty-rpm branch June 28, 2024 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pkg_rpm fails trying to create an empty rpm package

2 participants