summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/lib/recipetool/create.py44
1 files changed, 35 insertions, 9 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index 5f90b10353..ee27f8de85 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -247,6 +247,35 @@ def determine_from_filename(srcfile):
247 pv = None 247 pv = None
248 return (pn, pv) 248 return (pn, pv)
249 249
250def determine_from_url(srcuri):
251 """Determine name and version from a URL"""
252 pn = None
253 pv = None
254 parseres = urlparse.urlparse(srcuri.lower())
255 if parseres.path:
256 if 'github.com' in parseres.netloc:
257 res = re.search(r'.*/(.*?)/archive/(.*)-final\.(tar|zip)', parseres.path)
258 if res:
259 pn = res.group(1).strip().replace('_', '-')
260 pv = res.group(2).strip().replace('_', '.')
261 else:
262 res = re.search(r'.*/(.*?)/archive/v?(.*)\.(tar|zip)', parseres.path)
263 if res:
264 pn = res.group(1).strip().replace('_', '-')
265 pv = res.group(2).strip().replace('_', '.')
266 elif 'bitbucket.org' in parseres.netloc:
267 res = re.search(r'.*/(.*?)/get/[a-zA-Z_-]*([0-9][0-9a-zA-Z_.]*)\.(tar|zip)', parseres.path)
268 if res:
269 pn = res.group(1).strip().replace('_', '-')
270 pv = res.group(2).strip().replace('_', '.')
271
272 if not pn and not pv:
273 srcfile = os.path.basename(parseres.path.rstrip('/'))
274 pn, pv = determine_from_filename(srcfile)
275
276 logger.debug('Determined from source URL: name = "%s", version = "%s"' % (pn, pv))
277 return (pn, pv)
278
250def supports_srcrev(uri): 279def supports_srcrev(uri):
251 localdata = bb.data.createCopy(tinfoil.config_data) 280 localdata = bb.data.createCopy(tinfoil.config_data)
252 # This is a bit sad, but if you don't have this set there can be some 281 # This is a bit sad, but if you don't have this set there can be some
@@ -430,15 +459,12 @@ def create_recipe(args):
430 realpv = None 459 realpv = None
431 460
432 if srcuri and not realpv or not pn: 461 if srcuri and not realpv or not pn:
433 parseres = urlparse.urlparse(srcuri) 462 name_pn, name_pv = determine_from_url(srcuri)
434 if parseres.path: 463 if name_pn and not pn:
435 srcfile = os.path.basename(parseres.path.rstrip('/')) 464 pn = name_pn
436 name_pn, name_pv = determine_from_filename(srcfile) 465 if name_pv and not realpv:
437 logger.debug('Determined from filename: name = "%s", version = "%s"' % (name_pn, name_pv)) 466 realpv = name_pv
438 if name_pn and not pn: 467
439 pn = name_pn
440 if name_pv and not realpv:
441 realpv = name_pv
442 468
443 if not srcuri: 469 if not srcuri:
444 lines_before.append('# No information for SRC_URI yet (only an external source tree was specified)') 470 lines_before.append('# No information for SRC_URI yet (only an external source tree was specified)')