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

Append changelog content to RPM spec file #726

Merged
merged 1 commit into from
Aug 17, 2023
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
14 changes: 13 additions & 1 deletion pkg/make_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def __init__(self, name, version, release, arch, rpmbuild_path,
self.description_file = None
self.install_script_file = None
self.file_list_path = None
self.changelog = None

self.pre_scriptlet = None
self.post_scriptlet = None
Expand Down Expand Up @@ -230,6 +231,7 @@ def SetupWorkdir(self,
post_scriptlet_path=None,
preun_scriptlet_path=None,
postun_scriptlet_path=None,
changelog_file=None,
file_list_path=None):
"""Create the needed structure in the workdir."""

Expand Down Expand Up @@ -270,8 +272,13 @@ def SetupWorkdir(self,
'POST_SCRIPTLET': "%post\n" + self.post_scriptlet,
'PREUN_SCRIPTLET': "%preun\n" + self.preun_scriptlet,
'POSTUN_SCRIPTLET': "%postun\n" + self.postun_scriptlet,
'CHANGELOG': ""
}

if changelog_file:
self.changelog = SlurpFile(os.path.join(original_dir, changelog_file))
tpl_replacements["CHANGELOG"] = "%changelog\n" + self.changelog
aiuto marked this conversation as resolved.
Show resolved Hide resolved

# If the spec file has "Version" and "Release" tags specified in the spec
# file's preamble, the values are filled in immediately afterward. These go
# into "replacements". This is typically only the case for the "original"
Expand Down Expand Up @@ -423,6 +430,7 @@ def Build(self, spec_file, out_file,
preun_scriptlet_path=None,
postun_scriptlet_path=None,
file_list_path=None,
changelog_file=None,
rpmbuild_args=None):
"""Build the RPM described by the spec_file, with other metadata in keyword arguments"""

Expand All @@ -442,7 +450,8 @@ def Build(self, spec_file, out_file,
pre_scriptlet_path=pre_scriptlet_path,
post_scriptlet_path=post_scriptlet_path,
preun_scriptlet_path=preun_scriptlet_path,
postun_scriptlet_path=postun_scriptlet_path)
postun_scriptlet_path=postun_scriptlet_path,
changelog_file=changelog_file)
status = self.CallRpmBuild(dirname, rpmbuild_args or [])
self.SaveResult(out_file)

Expand Down Expand Up @@ -491,6 +500,8 @@ def main(argv):
help='File containing the RPM %preun scriptlet, if to be substituted')
parser.add_argument('--postun_scriptlet',
help='File containing the RPM %postun scriptlet, if to be substituted')
parser.add_argument('--changelog',
help='File containing the RPM changelog text')

parser.add_argument('--rpmbuild_arg', dest='rpmbuild_args', action='append',
help='Any additional arguments to pass to rpmbuild')
Expand All @@ -514,6 +525,7 @@ def main(argv):
post_scriptlet_path=options.post_scriptlet,
preun_scriptlet_path=options.preun_scriptlet,
postun_scriptlet_path=options.postun_scriptlet,
changelog_file=options.changelog,
rpmbuild_args=options.rpmbuild_args)
except NoRpmbuildFoundError:
print('ERROR: rpmbuild is required but is not present in PATH')
Expand Down
2 changes: 2 additions & 0 deletions pkg/rpm/template.spec.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ ${POST_SCRIPTLET}
${PREUN_SCRIPTLET}

${POSTUN_SCRIPTLET}

${CHANGELOG}
10 changes: 5 additions & 5 deletions pkg/rpm_pfg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ def _pkg_rpm_impl(ctx):
files.append(description_file)
args.append("--description=" + description_file.path)

if ctx.attr.changelog:
files.append(ctx.file.changelog)
args.append("--changelog=" + ctx.file.changelog.path)

#### Non-procedurally-generated scriptlets

substitutions = {}
Expand Down Expand Up @@ -432,11 +436,7 @@ def _pkg_rpm_impl(ctx):

args.append("--out_file=" + output_file.path)

# Add data files.
if ctx.file.changelog:
files.append(ctx.file.changelog)
args.append(ctx.file.changelog.path)

# Add data files
files += ctx.files.srcs

#### Consistency checking; input processing
Expand Down