| |
@@ -2372,11 +2372,11 @@
|
| |
with open(os.path.join(self.path, 'clog'), 'w') as clog:
|
| |
clog.writelines(clog_lines)
|
| |
|
| |
- def compile(self, arch=None, short=False, builddir=None, nocheck=False):
|
| |
+ def compile(self, arch=None, short=False, builddir=None, nocheck=False, define=None):
|
| |
"""Run rpmbuild -bc
|
| |
|
| |
- optionally for a specific arch, or short-circuit it, or
|
| |
- define an alternate builddir
|
| |
+ optionally for a specific arch, or short-circuit it,
|
| |
+ define an alternate builddir, or define some macro
|
| |
|
| |
Logs the output and returns nothing
|
| |
"""
|
| |
@@ -2389,6 +2389,9 @@
|
| |
cmd.append("--define '_builddir %s'" % os.path.abspath(builddir))
|
| |
if arch:
|
| |
cmd.extend(['--target', arch])
|
| |
+ if define:
|
| |
+ for entry in define:
|
| |
+ cmd.extend(['--define', entry])
|
| |
if short:
|
| |
cmd.append('--short-circuit')
|
| |
if nocheck:
|
| |
@@ -2425,16 +2428,17 @@
|
| |
# This should have a try and catch koji errors
|
| |
self.kojisession.uploadWrapper(file, path, callback=callback)
|
| |
|
| |
- def install(self, arch=None, short=False, builddir=None, nocheck=False,
|
| |
- buildrootdir=None):
|
| |
+ def install(self, arch=None, short=False, builddir=None,
|
| |
+ nocheck=False, buildrootdir=None, define=None):
|
| |
"""Run ``rpmbuild -bi``
|
| |
|
| |
- optionally for a specific arch, short-circuit it, or
|
| |
- define an alternative builddir
|
| |
+ optionally for a specific arch, short-circuit it,
|
| |
+ define an alternative builddir, or define rpmbuild macros
|
| |
|
| |
Logs the output and returns nothing
|
| |
|
| |
:param str arch: specify a specific arch.
|
| |
+ :param list define: specify a list of rpmbuild macros.
|
| |
:param bool short: short-circuit it.
|
| |
:param str builddir: alternate builddir.
|
| |
:param bool nocheck: do not check.
|
| |
@@ -2452,6 +2456,9 @@
|
| |
cmd.append("--define '_builddir %s'" % os.path.abspath(builddir))
|
| |
if arch:
|
| |
cmd.extend(['--target', arch])
|
| |
+ if define:
|
| |
+ for entry in define:
|
| |
+ cmd.extend(['--define', entry])
|
| |
if short:
|
| |
cmd.append('--short-circuit')
|
| |
if nocheck:
|
| |
@@ -2510,7 +2517,7 @@
|
| |
self._run_command(cmd, shell=True)
|
| |
|
| |
def local(self, localargs, arch=None, hashtype=None, builddir=None,
|
| |
- buildrootdir=None):
|
| |
+ buildrootdir=None, define=None):
|
| |
"""rpmbuild locally for given arch.
|
| |
|
| |
Takes localargs (passed to rpmbuild), arch to build for, and hashtype
|
| |
@@ -2521,6 +2528,7 @@
|
| |
`.build-{version}-{release}.log`.
|
| |
|
| |
:param str arch: to optionally build for a specific arch.
|
| |
+ :param list define: optional list of rpmbuild macros.
|
| |
:param str hashtype: an alternative algorithm used for payload file
|
| |
digests.
|
| |
:param str builddir: an alternative builddir.
|
| |
@@ -2551,6 +2559,9 @@
|
| |
% hashtype])
|
| |
if arch:
|
| |
cmd.extend(['--target', arch])
|
| |
+ if define:
|
| |
+ for entry in define:
|
| |
+ cmd.extend(['--define', entry])
|
| |
if self.quiet:
|
| |
cmd.append('--quiet')
|
| |
if buildrootdir:
|
| |
@@ -2807,11 +2818,12 @@
|
| |
|
| |
self.repo.index.add(['sources', '.gitignore'])
|
| |
|
| |
- def prep(self, arch=None, builddir=None, buildrootdir=None):
|
| |
+ def prep(self, arch=None, builddir=None, buildrootdir=None, define=None):
|
| |
"""Run ``rpmbuild -bp``
|
| |
|
| |
:param str arch: optional to run prep section for a specific arch. By
|
| |
default, local system arch will be used.
|
| |
+ :param list define: an optional list of rpmbuild macros.
|
| |
:param str builddir: an alternative builddir.
|
| |
:param str buildrootdir: an alternative buildrootdir.
|
| |
|
| |
@@ -2827,6 +2839,9 @@
|
| |
cmd.append("--define '_builddir %s'" % os.path.abspath(builddir))
|
| |
if arch:
|
| |
cmd.extend(['--target', arch])
|
| |
+ if define:
|
| |
+ for entry in define:
|
| |
+ cmd.extend(['--define', entry])
|
| |
if self.quiet:
|
| |
cmd.append('--quiet')
|
| |
if buildrootdir:
|
| |
@@ -2836,7 +2851,7 @@
|
| |
# Run the command
|
| |
self._run_command(cmd, shell=True)
|
| |
|
| |
- def srpm(self, hashtype=None):
|
| |
+ def srpm(self, hashtype=None, define=None, builddir=None, buildrootdir=None, arch=None):
|
| |
"""Create an srpm using hashtype from content
|
| |
|
| |
Requires sources already downloaded. The generated SRPM file will be
|
| |
@@ -2844,6 +2859,11 @@
|
| |
|
| |
:param str hashtype: an alternative algorithm used for payload file
|
| |
digests.
|
| |
+ :param list define: an optional list of rpmbuild macros.
|
| |
+ :param str builddir: optionally define an alternate builddir.
|
| |
+ :param str buildrootdir: optionally define an alternate buildrootdir.
|
| |
+ :param str arch: optional to run prep section for a specific arch. By
|
| |
+ default, local system arch will be used.
|
| |
"""
|
| |
|
| |
self.srpmname = os.path.join(self.path,
|
| |
@@ -2858,6 +2878,18 @@
|
| |
cmd.extend(self.rpmdefines)
|
| |
if self.quiet:
|
| |
cmd.append('--quiet')
|
| |
+ if define:
|
| |
+ for entry in define:
|
| |
+ cmd.extend(['--define', entry])
|
| |
+ if builddir:
|
| |
+ # Tack on a new builddir to the end of the defines
|
| |
+ cmd.append("--define '_builddir %s'" % os.path.abspath(builddir))
|
| |
+ if buildrootdir:
|
| |
+ cmd.append("--define '_buildrootdir {0}'".format(
|
| |
+ os.path.abspath(buildrootdir)))
|
| |
+ if arch:
|
| |
+ cmd.extend(['--target', arch])
|
| |
+
|
| |
# Figure out which hashtype to use, if not provided one
|
| |
if not hashtype:
|
| |
# Try to determine the dist
|
| |
@@ -2927,9 +2959,10 @@
|
| |
line_num += 1
|
| |
return [line_num, offset - offset_inc + 1]
|
| |
|
| |
- def verify_files(self, builddir=None, buildrootdir=None):
|
| |
+ def verify_files(self, builddir=None, buildrootdir=None, define=None):
|
| |
"""Run `rpmbuild -bl` to verify the `%files` section
|
| |
|
| |
+ :param list define: an optional list of rpmbuild macros.
|
| |
:param str builddir: optionally define an alternate builddir.
|
| |
:param str buildrootdir: optionally define an alternate buildrootdir.
|
| |
|
| |
@@ -2940,6 +2973,9 @@
|
| |
# setup the rpm command
|
| |
cmd = ['rpmbuild']
|
| |
cmd.extend(self.rpmdefines)
|
| |
+ if define:
|
| |
+ for entry in define:
|
| |
+ cmd.extend(['--define', entry])
|
| |
if builddir:
|
| |
# Tack on a new builddir to the end of the defines
|
| |
cmd.append("--define '_builddir %s'" % os.path.abspath(builddir))
|
| |
This should resolve https://pagure.io/rpkg/issue/379 along with the related fedpkg feature request.