summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch/osc.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/fetch/osc.py')
-rw-r--r--bitbake/lib/bb/fetch/osc.py143
1 files changed, 0 insertions, 143 deletions
diff --git a/bitbake/lib/bb/fetch/osc.py b/bitbake/lib/bb/fetch/osc.py
deleted file mode 100644
index 32237b9740..0000000000
--- a/bitbake/lib/bb/fetch/osc.py
+++ /dev/null
@@ -1,143 +0,0 @@
1# ex:ts=4:sw=4:sts=4:et
2# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
3"""
4Bitbake "Fetch" implementation for osc (Opensuse build service client).
5Based on the svn "Fetch" implementation.
6
7"""
8
9import os
10import sys
11import logging
12import bb
13from bb import data
14from bb import utils
15from bb.fetch import Fetch
16from bb.fetch import FetchError
17from bb.fetch import MissingParameterError
18from bb.fetch import runfetchcmd
19
20class Osc(Fetch):
21 """Class to fetch a module or modules from Opensuse build server
22 repositories."""
23
24 def supports(self, url, ud, d):
25 """
26 Check to see if a given url can be fetched with osc.
27 """
28 return ud.type in ['osc']
29
30 def localpath(self, url, ud, d):
31 if not "module" in ud.parm:
32 raise MissingParameterError("osc method needs a 'module' parameter.")
33
34 ud.module = ud.parm["module"]
35
36 # Create paths to osc checkouts
37 relpath = self._strip_leading_slashes(ud.path)
38 ud.pkgdir = os.path.join(data.expand('${OSCDIR}', d), ud.host)
39 ud.moddir = os.path.join(ud.pkgdir, relpath, ud.module)
40
41 if 'rev' in ud.parm:
42 ud.revision = ud.parm['rev']
43 else:
44 pv = data.getVar("PV", d, 0)
45 rev = Fetch.srcrev_internal_helper(ud, d)
46 if rev and rev != True:
47 ud.revision = rev
48 else:
49 ud.revision = ""
50
51 ud.localfile = data.expand('%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.path.replace('/', '.'), ud.revision), d)
52
53 return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
54
55 def _buildosccommand(self, ud, d, command):
56 """
57 Build up an ocs commandline based on ud
58 command is "fetch", "update", "info"
59 """
60
61 basecmd = data.expand('${FETCHCMD_osc}', d)
62
63 proto = ud.parm.get('proto', 'ocs')
64
65 options = []
66
67 config = "-c %s" % self.generate_config(ud, d)
68
69 if ud.revision:
70 options.append("-r %s" % ud.revision)
71
72 coroot = self._strip_leading_slashes(ud.path)
73
74 if command is "fetch":
75 osccmd = "%s %s co %s/%s %s" % (basecmd, config, coroot, ud.module, " ".join(options))
76 elif command is "update":
77 osccmd = "%s %s up %s" % (basecmd, config, " ".join(options))
78 else:
79 raise FetchError("Invalid osc command %s" % command)
80
81 return osccmd
82
83 def go(self, loc, ud, d):
84 """
85 Fetch url
86 """
87
88 logger.debug(2, "Fetch: checking for module directory '" + ud.moddir + "'")
89
90 if os.access(os.path.join(data.expand('${OSCDIR}', d), ud.path, ud.module), os.R_OK):
91 oscupdatecmd = self._buildosccommand(ud, d, "update")
92 logger.info("Update "+ loc)
93 # update sources there
94 os.chdir(ud.moddir)
95 logger.debug(1, "Running %s", oscupdatecmd)
96 runfetchcmd(oscupdatecmd, d)
97 else:
98 oscfetchcmd = self._buildosccommand(ud, d, "fetch")
99 logger.info("Fetch " + loc)
100 # check out sources there
101 bb.utils.mkdirhier(ud.pkgdir)
102 os.chdir(ud.pkgdir)
103 logger.debug(1, "Running %s", oscfetchcmd)
104 runfetchcmd(oscfetchcmd, d)
105
106 os.chdir(os.path.join(ud.pkgdir + ud.path))
107 # tar them up to a defined filename
108 try:
109 runfetchcmd("tar -czf %s %s" % (ud.localpath, ud.module), d)
110 except:
111 t, v, tb = sys.exc_info()
112 try:
113 os.unlink(ud.localpath)
114 except OSError:
115 pass
116 raise t, v, tb
117
118 def supports_srcrev(self):
119 return False
120
121 def generate_config(self, ud, d):
122 """
123 Generate a .oscrc to be used for this run.
124 """
125
126 config_path = os.path.join(data.expand('${OSCDIR}', d), "oscrc")
127 bb.utils.remove(config_path)
128
129 f = open(config_path, 'w')
130 f.write("[general]\n")
131 f.write("apisrv = %s\n" % ud.host)
132 f.write("scheme = http\n")
133 f.write("su-wrapper = su -c\n")
134 f.write("build-root = %s\n" % data.expand('${WORKDIR}', d))
135 f.write("urllist = http://moblin-obs.jf.intel.com:8888/build/%(project)s/%(repository)s/%(buildarch)s/:full/%(name)s.rpm\n")
136 f.write("extra-pkgs = gzip\n")
137 f.write("\n")
138 f.write("[%s]\n" % ud.host)
139 f.write("user = %s\n" % ud.parm["user"])
140 f.write("pass = %s\n" % ud.parm["pswd"])
141 f.close()
142
143 return config_path