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:31 +0100 |
| commit | b0d39aa3d2e0a3a0a53a22f7136a80c31ab50bc4 (patch) | |
| tree | b0bfa59b71122ebb638fae706f9b353f0e9f326d /bitbake/lib/bb/fetch2 | |
| parent | 23103d45c0012328870977de7165ba048730f4eb (diff) | |
| download | poky-b0d39aa3d2e0a3a0a53a22f7136a80c31ab50bc4.tar.gz | |
bitbake: 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.
(Bitbake rev: aa4cee1bb7415c498e4dc6af4dbb3d0c841faf2e)
Signed-off-by: Gunjan Gupta <viraniac@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2')
| -rw-r--r-- | bitbake/lib/bb/fetch2/osc.py | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/bitbake/lib/bb/fetch2/osc.py b/bitbake/lib/bb/fetch2/osc.py index eb0f82c8e6..dd02f03780 100644 --- a/bitbake/lib/bb/fetch2/osc.py +++ b/bitbake/lib/bb/fetch2/osc.py | |||
| @@ -9,6 +9,7 @@ Based on the svn "Fetch" implementation. | |||
| 9 | 9 | ||
| 10 | import logging | 10 | import logging |
| 11 | import os | 11 | import os |
| 12 | import re | ||
| 12 | import bb | 13 | import bb |
| 13 | from bb.fetch2 import FetchMethod | 14 | from bb.fetch2 import FetchMethod |
| 14 | from bb.fetch2 import FetchError | 15 | from bb.fetch2 import FetchError |
| @@ -60,26 +61,49 @@ class Osc(FetchMethod): | |||
| 60 | 61 | ||
| 61 | basecmd = d.getVar("FETCHCMD_osc") or "/usr/bin/env osc" | 62 | basecmd = d.getVar("FETCHCMD_osc") or "/usr/bin/env osc" |
| 62 | 63 | ||
| 63 | proto = ud.parm.get('protocol', 'ocs') | 64 | proto = ud.parm.get('protocol', 'https') |
| 64 | 65 | ||
| 65 | options = [] | 66 | options = [] |
| 66 | 67 | ||
| 67 | config = "-c %s" % self.generate_config(ud, d) | 68 | config = "-c %s" % self.generate_config(ud, d) |
| 68 | 69 | ||
| 69 | if ud.revision: | 70 | if getattr(ud, 'revision', ''): |
| 70 | options.append("-r %s" % ud.revision) | 71 | options.append("-r %s" % ud.revision) |
| 71 | 72 | ||
| 72 | coroot = self._strip_leading_slashes(ud.path) | 73 | coroot = self._strip_leading_slashes(ud.path) |
| 73 | 74 | ||
| 74 | if command == "fetch": | 75 | if command == "fetch": |
| 75 | osccmd = "%s %s co %s/%s %s" % (basecmd, config, coroot, ud.module, " ".join(options)) | 76 | osccmd = "%s %s -A %s://%s co %s/%s %s" % (basecmd, config, proto, ud.host, coroot, ud.module, " ".join(options)) |
| 76 | elif command == "update": | 77 | elif command == "update": |
| 77 | osccmd = "%s %s up %s" % (basecmd, config, " ".join(options)) | 78 | osccmd = "%s %s -A %s://%s up %s" % (basecmd, config, proto, ud.host, " ".join(options)) |
| 79 | elif command == "api_source": | ||
| 80 | osccmd = "%s %s -A %s://%s api source/%s/%s" % (basecmd, config, proto, ud.host, coroot, ud.module) | ||
| 78 | else: | 81 | else: |
| 79 | raise FetchError("Invalid osc command %s" % command, ud.url) | 82 | raise FetchError("Invalid osc command %s" % command, ud.url) |
| 80 | 83 | ||
| 81 | return osccmd | 84 | return osccmd |
| 82 | 85 | ||
| 86 | def _latest_revision(self, ud, d, name): | ||
| 87 | """ | ||
| 88 | Fetch latest revision for the given package | ||
| 89 | """ | ||
| 90 | api_source_cmd = self._buildosccommand(ud, d, "api_source") | ||
| 91 | |||
| 92 | output = runfetchcmd(api_source_cmd, d) | ||
| 93 | match = re.match('<directory ?.* rev="(\d+)".*>', output) | ||
| 94 | if match is None: | ||
| 95 | raise FetchError("Unable to parse osc response", ud.url) | ||
| 96 | return match.groups()[0] | ||
| 97 | |||
| 98 | def _revision_key(self, ud, d, name): | ||
| 99 | """ | ||
| 100 | Return a unique key for the url | ||
| 101 | """ | ||
| 102 | # Collapse adjacent slashes | ||
| 103 | slash_re = re.compile(r"/+") | ||
| 104 | rev = getattr(ud, 'revision', "latest") | ||
| 105 | return "osc:%s%s.%s.%s" % (ud.host, slash_re.sub(".", ud.path), name, rev) | ||
| 106 | |||
| 83 | def download(self, ud, d): | 107 | def download(self, ud, d): |
| 84 | """ | 108 | """ |
| 85 | Fetch url | 109 | Fetch url |
| @@ -123,7 +147,7 @@ class Osc(FetchMethod): | |||
| 123 | os.remove(config_path) | 147 | os.remove(config_path) |
| 124 | 148 | ||
| 125 | f = open(config_path, 'w') | 149 | f = open(config_path, 'w') |
| 126 | proto = ud.parm.get('proto', 'https') | 150 | proto = ud.parm.get('protocol', 'https') |
| 127 | f.write("[general]\n") | 151 | f.write("[general]\n") |
| 128 | f.write("apiurl = %s://%s\n" % (proto, ud.host)) | 152 | f.write("apiurl = %s://%s\n" % (proto, ud.host)) |
| 129 | f.write("su-wrapper = su -c\n") | 153 | f.write("su-wrapper = su -c\n") |
