return True
return False
+ @classmethod
+ def split_full_version(cls, version):
+ """
+ Parse full version string and split it into individual "version
+ components", i.e. upstreamversion, epoch and release
+
+ @param version: full version of a package
+ @type version: C{str}
+ @return: individual version components
+ @rtype: C{dict}
+
+ >>> RpmPkgPolicy.split_full_version("1")
+ {'release': None, 'epoch': None, 'upstreamversion': '1'}
+ >>> RpmPkgPolicy.split_full_version("1.2.3-5.3")
+ {'release': '5.3', 'epoch': None, 'upstreamversion': '1.2.3'}
+ >>> RpmPkgPolicy.split_full_version("3:1.2.3")
+ {'release': None, 'epoch': '3', 'upstreamversion': '1.2.3'}
+ >>> RpmPkgPolicy.split_full_version("3:1-0")
+ {'release': '0', 'epoch': '3', 'upstreamversion': '1'}
+ """
+ epoch = None
+ upstreamversion = None
+ release = None
+
+ e_vr = version.split(":", 1)
+ if len(e_vr) == 1:
+ v_r = e_vr[0].split("-", 1)
+ else:
+ epoch = e_vr[0]
+ v_r = e_vr[1].split("-", 1)
+ upstreamversion = v_r[0]
+ if len(v_r) > 1:
+ release = v_r[1]
+
+ return {'epoch': epoch,
+ 'upstreamversion': upstreamversion,
+ 'release': release}
+
+ @classmethod
+ def compose_full_version(cls, evr):
+ """
+ Compose a full version string from individual "version components",
+ i.e. epoch, version and release
+
+ @param evr: dict of version components
+ @type evr: C{dict} of C{str}
+ @return: full version
+ @rtype: C{str}
+
+ >>> RpmPkgPolicy.compose_full_version({'epoch': '', 'upstreamversion': '1.0'})
+ '1.0'
+ >>> RpmPkgPolicy.compose_full_version({'epoch': '2', 'upstreamversion': '1.0', 'release': None})
+ '2:1.0'
+ >>> RpmPkgPolicy.compose_full_version({'epoch': None, 'upstreamversion': '1', 'release': '0'})
+ '1-0'
+ >>> RpmPkgPolicy.compose_full_version({'epoch': '2', 'upstreamversion': '1.0', 'release': '2.3'})
+ '2:1.0-2.3'
+ >>> RpmPkgPolicy.compose_full_version({'epoch': '2', 'upstreamversion': '', 'release': '2.3'})
+ """
+ if 'upstreamversion' in evr and evr['upstreamversion']:
+ version = ""
+ if 'epoch' in evr and evr['epoch']:
+ version += "%s:" % evr['epoch']
+ version += evr['upstreamversion']
+ if 'release' in evr and evr['release']:
+ version += "-%s" % evr['release']
+ if version:
+ return version
+ return None
+
def get_upstream_tree(repo, spec, options):
"""Determine the upstream tree from the given options"""
if options.upstream_tree.upper() == 'TAG':
- upstream_tree = repo.version_to_tag(options.upstream_tag, spec.version, vendor="Upstream")
+ upstream_tree = repo.version_to_tag(options.upstream_tag, dict(upstreamversion=spec.version), "Upstream")
elif options.upstream_tree.upper() == 'BRANCH':
if not repo.has_branch(options.upstream_branch):
raise GbpError("%s is not a valid branch" % options.upstream_branch)
# Tag (note: tags the exported version)
if options.tag or options.tag_only:
gbp.log.info("Tagging %s" % spec.version)
- tag = repo.version_to_tag(options.packaging_tag, spec.version, vendor=options.vendor)
+ tag = repo.version_to_tag(options.packaging_tag, dict(upstreamversion=spec.version), options.vendor)
if options.retag and repo.has_tag(tag):
repo.delete_tag(tag)
repo.create_tag(name=tag, msg="%s release %s" % (options.vendor, spec.version),
if not options.tag_only:
if spec and options.notify:
summary = "Gbp-rpm %s" % ["failed", "successful"][not retval]
+ pkg_evr = {'upstreamversion': spec.version}
message = ("Build of %s %s %s" % (spec.name,
- spec.version,
+ RpmPkgPolicy.compose_full_version(pkg_evr),
["failed", "succeeded"][not retval]))
if not gbp.notifications.notify(summary, message, options.notify):
gbp.log.err("Failed to send notification")
gbp.log.info("Pristine-tar: commiting %s" % pristine_orig)
repo.pristine_tar.commit(pristine_orig, options.upstream_branch)
- tag = repo.version_to_tag(options.upstream_tag, version, vendor="Upstream")
+ tag = repo.version_to_tag(options.upstream_tag, dict(upstreamversion=version), "Upstream")
repo.create_tag(name=tag,
msg="Upstream version %s" % version,
commit=commit,
raise GbpError, "Can't parse spec"
# Find upstream version
- upstream_commit = repo.find_version(options.upstream_tag, spec.version, vendor="Upstream")
+ upstream_commit = repo.find_version(options.upstream_tag, dict(upstreamversion=spec.version), "Upstream")
if not upstream_commit:
raise GbpError, ("Couldn't find upstream version %s. Don't know on what base to import." % spec.version)
raise GbpError, "Can't parse spec"
# Find upstream version
- commit = repo.find_version(options.upstream_tag, spec.version, vendor="Upstream")
+ commit = repo.find_version(options.upstream_tag, dict(upstreamversion=spec.version), "Upstream")
if commit:
commits=[commit]
else:
raise GbpError, "Can't parse spec"
# Find upstream version
- upstream_commit = repo.find_version(options.upstream_tag, spec.version, vendor="Upstream")
+ upstream_commit = repo.find_version(options.upstream_tag, dict(upstreamversion=spec.version), "Upstream")
if not upstream_commit:
raise GbpError, ("Couldn't find upstream version %s. Don't know on what base to import." % spec.version)