| |
@@ -25,6 +25,7 @@
|
| |
import rpm
|
| |
|
| |
from .mock import Mock
|
| |
+ from .review_dirs import ReviewDirs
|
| |
from .review_error import ReviewError, SpecParseReviewError
|
| |
from .rpm_compat import spec
|
| |
from .settings import Settings
|
| |
@@ -67,11 +68,20 @@
|
| |
if not expanded.startswith("%"):
|
| |
rpm.delMacro(macro[1:])
|
| |
rpm.addMacro(macro[1:], expanded)
|
| |
+ # The %forgeversion and other RPM macros cannot guess the commit date if they don’t have access to the corresponding tarball
|
| |
+ rpm.addMacro("_sourcedir", ReviewDirs.srpm_unpacked)
|
| |
|
| |
def parse_spec():
|
| |
"""Let rpm parse the spec and build spec.spec (sic!)."""
|
| |
+ """Once the folder review-*/srpm-unpacked contains the tarball, running this function again will let RPM resolve %forgeversion properly. At that point, the version string will include the commit date and you can capture it into variables."""
|
| |
try:
|
| |
self.spec = spec(self.filename)
|
| |
+ self.name_vers_rel = [
|
| |
+ self.expand_tag(rpm.RPMTAG_NAME),
|
| |
+ self.expand_tag(rpm.RPMTAG_VERSION),
|
| |
+ "*",
|
| |
+ ]
|
| |
+ self.name_vers_rel[2] = self.expand_tag(rpm.RPMTAG_RELEASE)
|
| |
except Exception as ex:
|
| |
raise SpecParseReviewError("Can't parse specfile: " + ex.__str__())
|
| |
|
| |
@@ -82,17 +92,10 @@
|
| |
self._process_fonts_pkg()
|
| |
stdout = sys.stdout
|
| |
sys.stdout = _Null()
|
| |
- parse_spec()
|
| |
sys.stdout = stdout
|
| |
self._packages = None
|
| |
- self.name_vers_rel = [
|
| |
- self.expand_tag(rpm.RPMTAG_NAME),
|
| |
- self.expand_tag(rpm.RPMTAG_VERSION),
|
| |
- "*",
|
| |
- ]
|
| |
update_macros()
|
| |
parse_spec()
|
| |
- self.name_vers_rel[2] = self.expand_tag(rpm.RPMTAG_RELEASE)
|
| |
|
| |
name = property(lambda self: self.name_vers_rel[0])
|
| |
version = property(lambda self: self.name_vers_rel[1])
|
| |
So, _sourcedir must point to the directory where this tarball is located. RPM reads the filename, extracts the hash and the commit date (if present), and constructs the full version, that’s why correctly setting _sourcedir is crucial.
Without the tarball, %forgeversion can only include the hash, resulting in ERROR:
'No srpm found for (...)' (logs in /home/sergio/.cache/fedora-review.log)
or
'More than one srpm found for:
Fixes #519