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

Improve handling of sub rpms. #833

Merged
merged 1 commit into from
Mar 25, 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
20 changes: 11 additions & 9 deletions pkg/make_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,17 @@ def SetupWorkdir(self,

# Slurp in the scriptlets...
self.pre_scriptlet = \
SlurpFile(os.path.join(original_dir, pre_scriptlet_path)) if pre_scriptlet_path is not None else ''
SlurpFile(os.path.join(original_dir, pre_scriptlet_path)) if pre_scriptlet_path else ''
self.post_scriptlet = \
SlurpFile(os.path.join(original_dir, post_scriptlet_path)) if post_scriptlet_path is not None else ''
SlurpFile(os.path.join(original_dir, post_scriptlet_path)) if post_scriptlet_path else ''
self.preun_scriptlet = \
SlurpFile(os.path.join(original_dir, preun_scriptlet_path)) if preun_scriptlet_path is not None else ''
SlurpFile(os.path.join(original_dir, preun_scriptlet_path)) if preun_scriptlet_path else ''
self.postun_scriptlet = \
SlurpFile(os.path.join(original_dir, postun_scriptlet_path)) if postun_scriptlet_path is not None else ''
SlurpFile(os.path.join(original_dir, postun_scriptlet_path)) if postun_scriptlet_path else ''
self.posttrans_scriptlet = \
SlurpFile(os.path.join(original_dir, posttrans_scriptlet_path)) if posttrans_scriptlet_path is not None else ''
SlurpFile(os.path.join(original_dir, posttrans_scriptlet_path)) if posttrans_scriptlet_path else ''
self.subrpms = \
SlurpFile(os.path.join(original_dir, subrpms_file)) if subrpms_file is not None else ''
SlurpFile(os.path.join(original_dir, subrpms_file)) if subrpms_file else ''

# Then prepare for textual substitution. This is typically only the case for the
# experimental `pkg_rpm`.
Expand All @@ -279,7 +279,7 @@ def SetupWorkdir(self,
'PREUN_SCRIPTLET': ("%preun\n" + self.preun_scriptlet) if self.preun_scriptlet else "",
'POSTUN_SCRIPTLET': ("%postun\n" + self.postun_scriptlet) if self.postun_scriptlet else "",
'POSTTRANS_SCRIPTLET': ("%posttrans\n" + self.posttrans_scriptlet) if self.posttrans_scriptlet else "",
'SUBRPMS' : (self.subrpms if self.subrpms else ""),
'SUBRPMS' : self.subrpms,
'CHANGELOG': ""
}

Expand Down Expand Up @@ -362,11 +362,13 @@ def CallRpmBuild(self, dirname, rpmbuild_args):
args.append('-vv')

# Common options
# NOTE: There may be a need to add '--define', 'buildsubdir .' for some
# rpmbuild versions. But that breaks other rpmbuild versions, so before
# adding it back in, add extensive tests.
args += [
'--define', '_topdir %s' % dirname,
'--define', '_tmppath %s/TMP' % dirname,
'--define', '_builddir %s/BUILD' % dirname,
'--define', 'buildsubdir .',
aiuto marked this conversation as resolved.
Show resolved Hide resolved
'--bb',
'--buildroot=%s' % buildroot,
] # yapf: disable
Expand Down Expand Up @@ -467,7 +469,7 @@ def Build(self, spec_file, out_file, subrpm_out_files=None,
spec_file = os.path.join(original_dir, spec_file)
out_file = os.path.join(original_dir, out_file)

if subrpm_out_files is not None:
if subrpm_out_files:
subrpm_out_files = (s.split(':') for s in subrpm_out_files)
subrpm_out_files = [
(s[0], os.path.join(original_dir, s[1])) for s in subrpm_out_files]
Expand Down
18 changes: 6 additions & 12 deletions pkg/rpm_pfg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -666,27 +666,21 @@ def _pkg_rpm_impl(ctx):
_process_dep(dep, rpm_ctx)

#### subrpms
subrpm_file = ctx.actions.declare_file(
"{}.spec.subrpms".format(rpm_name),
)
if ctx.attr.subrpms:
subrpm_lines = []

for s in ctx.attr.subrpms:
subrpm_lines += _process_subrpm(ctx, rpm_name, s[PackageSubRPMInfo], rpm_ctx)
subrpm_lines.extend(_process_subrpm(ctx, rpm_name, s[PackageSubRPMInfo], rpm_ctx))

ctx.actions.write(
output = subrpm_file,
content = "\n".join(subrpm_lines),
subrpm_file = ctx.actions.declare_file(
"{}.spec.subrpms".format(rpm_name),
)
else:
ctx.actions.write(
output = subrpm_file,
content = "# no subrpms",
content = "\n".join(subrpm_lines),
)
files.append(subrpm_file)
rpm_ctx.make_rpm_args.append("--subrpms=" + subrpm_file.path)

files.append(subrpm_file)
rpm_ctx.make_rpm_args.append("--subrpms=" + subrpm_file.path)
#### Procedurally-generated scripts/lists (%install, %files)

# We need to write these out regardless of whether we are using
Expand Down