| |
@@ -67,6 +67,11 @@
|
| |
# The SafeConfigParser class has been renamed to ConfigParser in Python 3.2.
|
| |
ConfigParser = configparser.ConfigParser
|
| |
|
| |
+ try:
|
| |
+ from rpmautospec import specfile_uses_rpmautospec
|
| |
+ except ImportError:
|
| |
+ specfile_uses_rpmautospec = None
|
| |
+
|
| |
|
| |
class NullHandler(logging.Handler):
|
| |
"""Null logger to avoid spurious messages, add a handler in app code"""
|
| |
@@ -156,6 +161,8 @@
|
| |
self._nvr = None
|
| |
# The rpm release of the cloned package
|
| |
self._rel = None
|
| |
+ # Whether the spec file uses %autorelease
|
| |
+ self._uses_autorelease = None
|
| |
# The cloned repo object
|
| |
self._repo = None
|
| |
# The rpm defines used when calling rpm
|
| |
@@ -672,20 +679,36 @@
|
| |
@property
|
| |
def rel(self):
|
| |
"""This property ensures the rel attribute"""
|
| |
- if not self._rel:
|
| |
+ if self._rel is None:
|
| |
self.load_nameverrel()
|
| |
return(self._rel)
|
| |
|
| |
+ @property
|
| |
+ def uses_autorelease(self):
|
| |
+ if self._uses_autorelease is None:
|
| |
+ self.load_nameverrel()
|
| |
+ return self._uses_autorelease
|
| |
+
|
| |
def load_nameverrel(self):
|
| |
"""Set the release of a package."""
|
| |
|
| |
+ 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
|
| |
+ )
|
| |
+ else:
|
| |
+ # Set to 0 so it evaluates false-ish but differs from (unset) None.
|
| |
+ self._uses_autorelease = 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.
|
| |
cmd.extend(['-q', '--qf', '"??%{NAME} %{EPOCH} %{VERSION} %{RELEASE}??"',
|
| |
- '--specfile', '"%s"' % os.path.join(self.path, self.spec)])
|
| |
+ '--specfile', '"%s"' % specfile_path])
|
| |
joined_cmd = ' '.join(cmd)
|
| |
try:
|
| |
proc = subprocess.Popen(joined_cmd, shell=True,
|
| |
@@ -694,10 +717,8 @@
|
| |
stderr=subprocess.PIPE)
|
| |
output, err = proc.communicate()
|
| |
except Exception as e:
|
| |
- if err:
|
| |
- self.log.debug('Errors occoured while running following command to get N-V-R-E:')
|
| |
- self.log.debug(joined_cmd)
|
| |
- self.log.error(err)
|
| |
+ self.log.debug('Errors occoured while running following command to get N-V-R-E:')
|
| |
+ self.log.debug(joined_cmd)
|
| |
raise rpkgError('Could not query n-v-r of %s: %s'
|
| |
% (self.repo_name, e))
|
| |
if err:
|
| |
@@ -2275,9 +2296,9 @@
|
| |
' in following messages.')
|
| |
build_reference = self.repo_name
|
| |
|
| |
- # see if this build has been done. Does not check builds within
|
| |
- # a chain
|
| |
- if nvr_check and not scratch and not url.endswith('.src.rpm'):
|
| |
+ # See if this build has been done. Does not check builds within
|
| |
+ # a chain, or if the %autorelease macro is used.
|
| |
+ if (nvr_check or self.uses_autorelease) and not scratch and not url.endswith('.src.rpm'):
|
| |
build = self.kojisession.getBuild(self.nvr)
|
| |
if build:
|
| |
if build['state'] == 1:
|
| |
If a spec file sets the release field to the %autorelease macro, don't
even attempt to check if the build exists already, as using the macro
ensures that a new release number is used.
Fixes: https://pagure.io/fedora-infra/rpmautospec/issue/109
Signed-off-by: Nils Philippsen nils@redhat.com