diff options
Diffstat (limited to 'pkg/make_rpm.py')
-rw-r--r-- | pkg/make_rpm.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/pkg/make_rpm.py b/pkg/make_rpm.py index e2ffca0..dd30a49 100644 --- a/pkg/make_rpm.py +++ b/pkg/make_rpm.py @@ -198,6 +198,7 @@ class RpmBuilder(object): 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 @@ -230,6 +231,8 @@ class RpmBuilder(object): post_scriptlet_path=None, preun_scriptlet_path=None, postun_scriptlet_path=None, + posttrans_scriptlet_path=None, + changelog_file=None, file_list_path=None): """Create the needed structure in the workdir.""" @@ -262,16 +265,24 @@ class RpmBuilder(object): SlurpFile(os.path.join(original_dir, preun_scriptlet_path)) if preun_scriptlet_path is not None else '' self.postun_scriptlet = \ SlurpFile(os.path.join(original_dir, postun_scriptlet_path)) if postun_scriptlet_path is not None else '' + self.posttrans_scriptlet = \ + SlurpFile(os.path.join(original_dir, posttrans_scriptlet_path)) if posttrans_scriptlet_path is not None else '' # Then prepare for textual substitution. This is typically only the case for the # experimental `pkg_rpm`. tpl_replacements = { - 'PRE_SCRIPTLET': "%pre\n" + self.pre_scriptlet, - 'POST_SCRIPTLET': "%post\n" + self.post_scriptlet, - 'PREUN_SCRIPTLET': "%preun\n" + self.preun_scriptlet, - 'POSTUN_SCRIPTLET': "%postun\n" + self.postun_scriptlet, + 'PRE_SCRIPTLET': ("%pre\n" + self.pre_scriptlet) if self.pre_scriptlet else "", + 'POST_SCRIPTLET': ("%post\n" + self.post_scriptlet) if self.post_scriptlet else "", + '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 "", + 'CHANGELOG': "" } + if changelog_file: + self.changelog = SlurpFile(os.path.join(original_dir, changelog_file)) + tpl_replacements["CHANGELOG"] = "%changelog\n" + self.changelog + # 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" @@ -350,6 +361,7 @@ class RpmBuilder(object): args += [ '--define', '_topdir %s' % dirname, '--define', '_tmppath %s/TMP' % dirname, + '--define', '_builddir %s/BUILD' % dirname, '--bb', '--buildroot=%s' % buildroot, ] # yapf: disable @@ -422,7 +434,9 @@ class RpmBuilder(object): post_scriptlet_path=None, preun_scriptlet_path=None, postun_scriptlet_path=None, + posttrans_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""" @@ -442,7 +456,9 @@ class RpmBuilder(object): 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, + posttrans_scriptlet_path=posttrans_scriptlet_path, + changelog_file=changelog_file) status = self.CallRpmBuild(dirname, rpmbuild_args or []) self.SaveResult(out_file) @@ -491,6 +507,10 @@ 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('--posttrans_scriptlet', + help='File containing the RPM %posttrans 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') @@ -514,6 +534,8 @@ def main(argv): post_scriptlet_path=options.post_scriptlet, preun_scriptlet_path=options.preun_scriptlet, postun_scriptlet_path=options.postun_scriptlet, + posttrans_scriptlet_path=options.posttrans_scriptlet, + changelog_file=options.changelog, rpmbuild_args=options.rpmbuild_args) except NoRpmbuildFoundError: print('ERROR: rpmbuild is required but is not present in PATH') |