aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/bb/fetch2/osc.py34
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")