Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable pkg_rpm and pkg_subrpm to create empty RPMs #859

Merged
merged 4 commits into from
Apr 24, 2024

Conversation

kellyma2
Copy link
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.
Copy link
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.

pkg/rpm_pfg.bzl Outdated Show resolved Hide resolved
pkg/rpm_pfg.bzl Outdated Show resolved Hide resolved
@kellyma2
Copy link
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
2 checks passed
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