| |
@@ -72,6 +72,13 @@
|
| |
except ImportError:
|
| |
specfile_uses_rpmautospec = None
|
| |
|
| |
+ try:
|
| |
+ from rpmautospec import process_distgit as rpmautospec_process_distgit
|
| |
+ from rpmautospec import calculate_release_number as rpmautospec_calculate_release_number
|
| |
+ except ImportError:
|
| |
+ rpmautospec_process_distgit = None
|
| |
+ rpmautospec_calculate_release_number = None
|
| |
+
|
| |
|
| |
class NullHandler(logging.Handler):
|
| |
"""Null logger to avoid spurious messages, add a handler in app code"""
|
| |
@@ -161,6 +168,8 @@
|
| |
self._rel = None
|
| |
# Whether the spec file uses %autorelease
|
| |
self._uses_autorelease = None
|
| |
+ # Whether the spec file uses rpmautospec features (at all)
|
| |
+ self._uses_rpmautospec = None
|
| |
# The cloned repo object
|
| |
self._repo = None
|
| |
# The rpm defines used when calling rpm
|
| |
@@ -646,21 +655,33 @@
|
| |
self.load_nameverrel()
|
| |
return self._uses_autorelease
|
| |
|
| |
+ @property
|
| |
+ def uses_rpmautospec(self):
|
| |
+ if self._uses_rpmautospec is None:
|
| |
+ self.load_nameverrel()
|
| |
+ return self._uses_rpmautospec
|
| |
+
|
| |
def load_nameverrel(self):
|
| |
"""Set the release of a package."""
|
| |
|
| |
+ cmd = ['rpm']
|
| |
+ cmd.extend(self.rpmdefines)
|
| |
+
|
| |
specfile_path = os.path.join(self.path, self.spec)
|
| |
|
| |
if specfile_uses_rpmautospec:
|
| |
self._uses_autorelease = specfile_uses_rpmautospec(
|
| |
specfile_path, check_autorelease=True, check_autochangelog=False
|
| |
)
|
| |
+ self._uses_rpmautospec = specfile_uses_rpmautospec(specfile_path)
|
| |
+ if self._uses_rpmautospec and rpmautospec_calculate_release_number:
|
| |
+ release_number = rpmautospec_calculate_release_number(specfile_path)
|
| |
+ cmd.append("--define '_rpmautospec_release_number %d'" % release_number)
|
| |
else:
|
| |
# Set to 0 so it evaluates false-ish but differs from (unset) None.
|
| |
self._uses_autorelease = 0
|
| |
+ self._uses_rpmautospec = 0
|
| |
|
| |
- cmd = ['rpm']
|
| |
- cmd.extend(self.rpmdefines)
|
| |
# We make sure there is a space at the end of our query so that
|
| |
# we can split it later. When there are subpackages, we get a
|
| |
# listing for each subpackage. We only care about the first.
|
| |
@@ -2575,19 +2596,30 @@
|
| |
% hashtype,
|
| |
"--define '_binary_filedigest_algorithm %s'"
|
| |
% hashtype])
|
| |
- cmd.extend(['-ba', os.path.join(self.path, self.spec)])
|
| |
- logfile = '.build-%s-%s.log' % (self.ver, self.rel)
|
| |
-
|
| |
- cmd = '%s 2>&1 | tee %s' % (' '.join(cmd), logfile)
|
| |
+ specpath = os.path.join(self.path, self.spec)
|
| |
+ tmpdir = None
|
| |
try:
|
| |
- # Since zsh is a widely used, which is supported by fedpkg
|
| |
- # actually, pipestatus is for checking the first command when zsh
|
| |
- # is used.
|
| |
- subprocess.check_call(
|
| |
- '%s; exit "${PIPESTATUS[0]} ${pipestatus[1]}"' % cmd,
|
| |
- shell=True)
|
| |
- except subprocess.CalledProcessError:
|
| |
- raise rpkgError(cmd)
|
| |
+ if not self.uses_rpmautospec or not rpmautospec_process_distgit:
|
| |
+ cmd.extend(['-ba', specpath])
|
| |
+ else:
|
| |
+ tmpdir = tempfile.mkdtemp(prefix="rpkg-rpmautospec")
|
| |
+ tmpspecpath = os.path.join(tmpdir, self.spec)
|
| |
+ rpmautospec_process_distgit(specpath, tmpspecpath)
|
| |
+ cmd.extend(['-ba', tmpspecpath])
|
| |
+ logfile = '.build-%s-%s.log' % (self.ver, self.rel)
|
| |
+
|
| |
+ cmd = '%s 2>&1 | tee %s' % (' '.join(cmd), logfile)
|
| |
+ try:
|
| |
+ # Since zsh is a widely used, which is supported by fedpkg
|
| |
+ # actually, pipestatus is for checking the first command when zsh
|
| |
+ # is used.
|
| |
+ subprocess.check_call(
|
| |
+ '%s; exit "${PIPESTATUS[0]} ${pipestatus[1]}"' % cmd,
|
| |
+ shell=True)
|
| |
+ except subprocess.CalledProcessError:
|
| |
+ raise rpkgError(cmd)
|
| |
+ finally:
|
| |
+ self._cleanup_tmp_dir(tmpdir)
|
| |
|
| |
# Not to be confused with mockconfig the property
|
| |
def mock_config(self, target=None, arch=None):
|
| |
@@ -2950,8 +2982,19 @@
|
| |
% hashtype,
|
| |
"--define '_binary_filedigest_algorithm %s'"
|
| |
% hashtype])
|
| |
- cmd.extend(['--nodeps', '-bs', os.path.join(self.path, self.spec)])
|
| |
- self._run_command(cmd, shell=True)
|
| |
+ specpath = os.path.join(self.path, self.spec)
|
| |
+ tmpdir = None
|
| |
+ try:
|
| |
+ if not self.uses_rpmautospec or not rpmautospec_process_distgit:
|
| |
+ cmd.extend(['--nodeps', '-bs', specpath])
|
| |
+ else:
|
| |
+ tmpdir = tempfile.mkdtemp(prefix="rpkg-rpmautospec")
|
| |
+ tmpspecpath = os.path.join(tmpdir, self.spec)
|
| |
+ rpmautospec_process_distgit(specpath, tmpspecpath)
|
| |
+ cmd.extend(['--nodeps', '-bs', tmpspecpath])
|
| |
+ self._run_command(cmd, shell=True)
|
| |
+ finally:
|
| |
+ self._cleanup_tmp_dir(tmpdir)
|
| |
|
| |
def unused_patches(self):
|
| |
"""Discover patches checked into source control that are not used
|
| |
If spec files use rpmautospec features, preprocess them into a temporary directory and point rpmbuild at the pre-processed spec file.
Depends-On: https://pagure.io/fedora-infra/rpmautospec/pull-request/183
If the necessary rpmautospec features aren't present (i.e. before fedora-infra/rpmautospec#183 is merged and release), all this will be skipped.
Also, calculate the release number and pass it to the macro when parsing the spec file which should make fedpkg/rpkg commands display/expect the right NVR when working on rpmautospec-enabled packages.