diff options
author | Gunjan Gupta <viraniac@gmail.com> | 2022-05-19 18:34:03 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-05-21 09:59:29 +0100 |
commit | aa4cee1bb7415c498e4dc6af4dbb3d0c841faf2e (patch) | |
tree | 6f914749326ab8fd66c8d6b602b845de5030fed9 /lib | |
parent | 4d671504a25863018ac51c21c005cef0a4d8f05c (diff) | |
download | bitbake-aa4cee1bb7415c498e4dc6af4dbb3d0c841faf2e.tar.gz |
fetch2/osc: Add support to query latest revision
Add support to query latest revision. This makes it possble to use
osc fetcher without specifying the rev parameter.
Signed-off-by: Gunjan Gupta <viraniac@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bb/fetch2/osc.py | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/lib/bb/fetch2/osc.py b/lib/bb/fetch2/osc.py index eb0f82c8e..dd02f0378 100644 --- a/lib/bb/fetch2/osc.py +++ b/lib/bb/fetch2/osc.py @@ -9,6 +9,7 @@ Based on the svn "Fetch" implementation. import logging import os +import re import bb from bb.fetch2 import FetchMethod from bb.fetch2 import FetchError @@ -60,26 +61,49 @@ class Osc(FetchMethod): basecmd = d.getVar("FETCHCMD_osc") or "/usr/bin/env osc" - proto = ud.parm.get('protocol', 'ocs') + proto = ud.parm.get('protocol', 'https') options = [] config = "-c %s" % self.generate_config(ud, d) - if ud.revision: + if getattr(ud, 'revision', ''): options.append("-r %s" % ud.revision) coroot = self._strip_leading_slashes(ud.path) if command == "fetch": - osccmd = "%s %s co %s/%s %s" % (basecmd, config, coroot, ud.module, " ".join(options)) + osccmd = "%s %s -A %s://%s co %s/%s %s" % (basecmd, config, proto, ud.host, coroot, ud.module, " ".join(options)) elif command == "update": - osccmd = "%s %s up %s" % (basecmd, config, " ".join(options)) + osccmd = "%s %s -A %s://%s up %s" % (basecmd, config, proto, ud.host, " ".join(options)) + elif command == "api_source": + osccmd = "%s %s -A %s://%s api source/%s/%s" % (basecmd, config, proto, ud.host, coroot, ud.module) else: raise FetchError("Invalid osc command %s" % command, ud.url) return osccmd + def _latest_revision(self, ud, d, name): + """ + Fetch latest revision for the given package + """ + api_source_cmd = self._buildosccommand(ud, d, "api_source") + + output = runfetchcmd(api_source_cmd, d) + match = re.match('<directory ?.* rev="(\d+)".*>', output) + if match is None: + raise FetchError("Unable to parse osc response", ud.url) + return match.groups()[0] + + def _revision_key(self, ud, d, name): + """ + Return a unique key for the url + """ + # Collapse adjacent slashes + slash_re = re.compile(r"/+") + rev = getattr(ud, 'revision', "latest") + return "osc:%s%s.%s.%s" % (ud.host, slash_re.sub(".", ud.path), name, rev) + def download(self, ud, d): """ Fetch url @@ -123,7 +147,7 @@ class Osc(FetchMethod): os.remove(config_path) f = open(config_path, 'w') - proto = ud.parm.get('proto', 'https') + proto = ud.parm.get('protocol', 'https') f.write("[general]\n") f.write("apiurl = %s://%s\n" % (proto, ud.host)) f.write("su-wrapper = su -c\n") |