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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/rpm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ def pkg_rpm(name, srcs = None, spec_file = None, subrpms = None, **kwargs):
depending on mode

"""
if srcs and spec_file:
if srcs != None and spec_file:
fail("Cannot determine which pkg_rpm rule to use. `srcs` and `spec_file` are mutually exclusive")

if subrpms and spec_file:
fail("Cannot build sub RPMs with a specfile. `subrpms` and `spec_file` are mutually exclusive")

if not srcs and not spec_file:
if srcs == None and not spec_file:
fail("Either `srcs` or `spec_file` must be provided.")

if srcs:
if srcs != None:
pkg_rpm_pfg(
name = name,
srcs = srcs,
Expand Down
21 changes: 14 additions & 7 deletions pkg/rpm_pfg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,14 @@ def _process_subrpm(ctx, rpm_name, rpm_info, rpm_ctx):
"%%files %s" % rpm_info.package_name,
]

for dep in rpm_info.srcs:
_process_dep(dep, sub_rpm_ctx)
if rpm_info.srcs:
for dep in rpm_info.srcs:
_process_dep(dep, sub_rpm_ctx)

rpm_lines += sub_rpm_ctx.rpm_files_list
else:
rpm_lines += "%defattr(-,root,root)"
aiuto marked this conversation as resolved.
Show resolved Hide resolved

rpm_lines += sub_rpm_ctx.rpm_files_list
rpm_lines += [""]

rpm_ctx.install_script_pieces.extend(sub_rpm_ctx.install_script_pieces)
Expand Down Expand Up @@ -702,10 +706,13 @@ def _pkg_rpm_impl(ctx):
rpm_files_file = ctx.actions.declare_file(
"{}.spec.files".format(rpm_name),
)
ctx.actions.write(
rpm_files_file,
"\n".join(rpm_ctx.rpm_files_list),
)
if rpm_ctx.rpm_files_list:
ctx.actions.write(
rpm_files_file,
"\n".join(rpm_ctx.rpm_files_list),
)
else:
ctx.actions.write(rpm_files_file, "%defattr(-,root,root)")
kellyma2 marked this conversation as resolved.
Show resolved Hide resolved

# TreeArtifact processing work
if rpm_ctx.packaged_directories:
Expand Down