summaryrefslogtreecommitdiff
path: root/gbp
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2012-04-23 12:51:08 +0300
committerJun Wang <junbill.wang@samsung.com>2016-01-27 21:42:09 +0800
commitdea4f78e3497a3080ad3069a1e0495d0a2544c25 (patch)
tree8d78c58764b3d802097c88ca8b84d77b80b1c071 /gbp
parenta112211ea9ed669bacb803b44dfd67fd6d00164e (diff)
downloadgit-buildpackage-dea4f78e3497a3080ad3069a1e0495d0a2544c25.tar.gz
git-buildpackage-dea4f78e3497a3080ad3069a1e0495d0a2544c25.tar.bz2
git-buildpackage-dea4f78e3497a3080ad3069a1e0495d0a2544c25.zip
rpm: add version parsing functions to pkg policy
Adds functions for version string generation and parsing. These are intended for parsing version strings taken e.g. from rpm filename or changelogs. Also, take these new version parsing functions into use in the rpm gbp scripts. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com> Conflicts: gbp/rpm/policy.py gbp/scripts/buildpackage_rpm.py gbp/scripts/import_orig_rpm.py gbp/scripts/pq_rpm.py
Diffstat (limited to 'gbp')
-rwxr-xr-xgbp/scripts/buildpackage_rpm.py10
-rwxr-xr-xgbp/scripts/import_orig_rpm.py4
-rwxr-xr-xgbp/scripts/pq_rpm.py58
3 files changed, 68 insertions, 4 deletions
diff --git a/gbp/scripts/buildpackage_rpm.py b/gbp/scripts/buildpackage_rpm.py
index dcfa3ace..cb3c3437 100755
--- a/gbp/scripts/buildpackage_rpm.py
+++ b/gbp/scripts/buildpackage_rpm.py
@@ -655,9 +655,14 @@ def main(argv):
# Tag (note: tags the exported version)
if options.tag or options.tag_only:
+<<<<<<< HEAD
gbp.log.info("Tagging %s" % RpmPkgPolicy.compose_full_version(spec.version))
commit_info = repo.get_commit_info(tree)
tag = packaging_tag_name(repo, spec, commit_info, options)
+=======
+ gbp.log.info("Tagging %s" % spec.version)
+ tag = repo.version_to_tag(options.packaging_tag, dict(upstreamversion=spec.version), options.vendor)
+>>>>>>> 96a8aae... rpm: add version parsing functions to pkg policy
if options.retag and repo.has_tag(tag):
repo.delete_tag(tag)
create_packaging_tag(repo, tag, commit=tree, version=spec.version,
@@ -698,8 +703,13 @@ def main(argv):
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,
+<<<<<<< HEAD
RpmPkgPolicy.compose_full_version(spec.version),
+=======
+ RpmPkgPolicy.compose_full_version(pkg_evr),
+>>>>>>> 96a8aae... rpm: add version parsing functions to pkg policy
["failed", "succeeded"][not retval]))
if not gbp.notifications.notify(summary, message, options.notify):
gbp.log.err("Failed to send notification")
diff --git a/gbp/scripts/import_orig_rpm.py b/gbp/scripts/import_orig_rpm.py
index 0dd7c013..b1247f1e 100755
--- a/gbp/scripts/import_orig_rpm.py
+++ b/gbp/scripts/import_orig_rpm.py
@@ -299,12 +299,8 @@ def main(argv):
gbp.log.info("Pristine-tar: commiting %s" % pristine_orig)
repo.pristine_tar.commit(pristine_orig, options.upstream_branch)
-<<<<<<< HEAD
tag_str_fields = dict(upstreamversion=version, vendor="Upstream")
tag = repo.version_to_tag(options.upstream_tag, tag_str_fields)
-=======
- tag = repo.version_to_tag(options.upstream_tag, version, vendor="Upstream")
->>>>>>> 1a96ba7... rpm: add 'vendor' config option
repo.create_tag(name=tag,
msg="Upstream version %s" % version,
commit=commit,
diff --git a/gbp/scripts/pq_rpm.py b/gbp/scripts/pq_rpm.py
index 958185fb..19050dac 100755
--- a/gbp/scripts/pq_rpm.py
+++ b/gbp/scripts/pq_rpm.py
@@ -242,6 +242,7 @@ def parse_spec(options, repo, treeish=None):
else:
spec = spec_from_repo(repo, treeish, options.spec_file)
else:
+<<<<<<< HEAD
preferred_name = os.path.basename(repo.path) + '.spec'
if not treeish:
spec = guess_spec(options.packaging_dir, True, preferred_name)
@@ -261,6 +262,17 @@ def find_upstream_commit(repo, spec, upstream_tag):
tag_str_fields = {'upstreamversion': spec.upstreamversion,
'vendor': 'Upstream'}
upstream_commit = repo.find_version(upstream_tag, tag_str_fields)
+=======
+ specfilename = guess_spec(options.packaging_dir,
+ True,
+ os.path.basename(repo.path) + '.spec')
+ spec = SpecFile(specfilename)
+ except KeyError:
+ raise GbpError, "Can't parse spec"
+
+ # Find upstream version
+ upstream_commit = repo.find_version(options.upstream_tag, dict(upstreamversion=spec.version), "Upstream")
+>>>>>>> 96a8aae... rpm: add version parsing functions to pkg policy
if not upstream_commit:
raise GbpError("Couldn't find upstream version %s" %
spec.upstreamversion)
@@ -404,10 +416,26 @@ def import_spec_patches(repo, options):
if repo.get_branch() == pq_branch:
repo.force_head(upstream_commit, hard=True)
else:
+<<<<<<< HEAD
repo.create_branch(pq_branch, upstream_commit, force=True)
except GitRepositoryError as err:
raise GbpError("Cannot create patch-queue branch '%s': %s" %
(pq_branch, err))
+=======
+ specfilename = guess_spec(options.packaging_dir,
+ True,
+ os.path.basename(repo.path) + '.spec')
+ spec = SpecFile(specfilename)
+ except KeyError:
+ raise GbpError, "Can't parse spec"
+
+ # Find upstream version
+ commit = repo.find_version(options.upstream_tag, dict(upstreamversion=spec.version), "Upstream")
+ if commit:
+ commits=[commit]
+ else:
+ raise GbpError, ("Couldn't find upstream version %s. Don't know on what base to import." % spec.version)
+>>>>>>> 96a8aae... rpm: add version parsing functions to pkg policy
# Put patches in a safe place
if spec_treeish:
@@ -440,6 +468,7 @@ def import_spec_patches(repo, options):
pq_branch))
+<<<<<<< HEAD
def rebase_pq(repo, options):
"""Rebase pq branch on the correct upstream version (from spec file)."""
current = repo.get_branch()
@@ -450,6 +479,35 @@ def rebase_pq(repo, options):
base = current
spec = parse_spec(options, repo)
upstream_commit = find_upstream_commit(repo, spec, options.upstream_tag)
+=======
+ return os.path.basename(spec.specfile)
+
+
+def rebase_pq(repo, branch, options):
+ if is_pq_branch(branch, options):
+ base = pq_branch_base(branch, options)
+ gbp.log.info("On '%s', switching to '%s'" % (branch, base))
+ branch = base
+ repo.set_branch(branch)
+
+ # Find and parse .spec file
+ try:
+ if options.spec_file != 'auto':
+ specfilename = options.spec_file
+ options.packaging_dir = os.path.dirname(specfilename)
+ else:
+ specfilename = guess_spec(options.packaging_dir,
+ True,
+ os.path.basename(repo.path) + '.spec')
+ spec = SpecFile(specfilename)
+ except KeyError:
+ raise GbpError, "Can't parse spec"
+
+ # Find upstream version
+ 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)
+>>>>>>> 96a8aae... rpm: add version parsing functions to pkg policy
switch_to_pq_branch(repo, base, options)
GitCommand("rebase")([upstream_commit])