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 all commits
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
16 changes: 12 additions & 4 deletions pkg/rpm_pfg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ PackageSubRPMInfo = provider(
},
)

# default mode for %files
DEFAULT_FILE_MODE = "%defattr(-,root,root)"

# TODO(nacl): __install, __cp
# {0} is the source, {1} is the dest
#
Expand Down Expand Up @@ -355,7 +358,11 @@ def _process_subrpm(ctx, rpm_name, rpm_info, rpm_ctx):
for dep in rpm_info.srcs:
_process_dep(dep, sub_rpm_ctx)

# rpmbuild will be unhappy if we have no files so we stick
# default file mode in for that scenario
rpm_lines += [DEFAULT_FILE_MODE]
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 +709,11 @@ 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),
)

# rpmbuild will be unhappy if we have no files so we stick
# default file mode in for that scenario
rpm_files_contents = [DEFAULT_FILE_MODE] + rpm_ctx.rpm_files_list
ctx.actions.write(rpm_files_file, "\n".join(rpm_files_contents))

# TreeArtifact processing work
if rpm_ctx.packaged_directories:
Expand Down