2013-02-08 21:02:56 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
2013-02-15 23:09:16 +08:00
|
|
|
# Copyright (c) 2013 Stefan Herbrechtsmeier, Bielefeld University
|
|
|
|
#
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import xml.etree.ElementTree as ElementTree
|
|
|
|
import hashlib
|
|
|
|
|
|
|
|
filename = 'package.xml'
|
|
|
|
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
filename = sys.argv[1]
|
2013-02-08 21:02:56 +08:00
|
|
|
|
2013-02-15 23:09:16 +08:00
|
|
|
if not os.path.isfile(filename):
|
|
|
|
exit(-1)
|
2013-02-08 21:02:56 +08:00
|
|
|
|
2013-02-15 23:09:16 +08:00
|
|
|
tree = ElementTree.parse(filename)
|
|
|
|
root = tree.getroot()
|
2013-02-08 21:02:56 +08:00
|
|
|
|
2013-02-15 23:09:16 +08:00
|
|
|
name = tree.findtext('name', '')
|
|
|
|
version = tree.findtext('version', '')
|
|
|
|
description = tree.findtext('description', '').strip()
|
|
|
|
license = tree.findtext('license', '')
|
|
|
|
homepage = tree.findtext('url', '')
|
2013-02-08 21:02:56 +08:00
|
|
|
|
2013-02-15 23:09:16 +08:00
|
|
|
f = file(filename)
|
|
|
|
license_line = ''
|
|
|
|
license_md5 = ''
|
|
|
|
i = 0
|
|
|
|
for line in f:
|
|
|
|
i += 1
|
|
|
|
if 'license' in line:
|
|
|
|
license_line = str(i)
|
|
|
|
md5 = hashlib.md5()
|
|
|
|
md5.update(line)
|
|
|
|
license_md5 = md5.hexdigest()
|
|
|
|
break
|
2013-02-08 21:02:56 +08:00
|
|
|
|
|
|
|
|
2013-02-15 23:09:16 +08:00
|
|
|
buildtools = []
|
|
|
|
for e in root.findall('buildtool_depend'):
|
|
|
|
buildtools.append(e.text)
|
2013-02-08 21:02:56 +08:00
|
|
|
|
2013-02-15 23:09:16 +08:00
|
|
|
depends = []
|
|
|
|
for e in root.findall('build_depend'):
|
|
|
|
depends.append(e.text.replace('_', '-'))
|
2013-02-08 21:02:56 +08:00
|
|
|
|
2013-02-15 23:09:16 +08:00
|
|
|
print(name + '_' + version + ".bb")
|
|
|
|
print('')
|
|
|
|
print('DESCRIPTION = "' + description + '"')
|
|
|
|
if homepage:
|
|
|
|
print('HOMEPAGE = "' + homepage + '"')
|
|
|
|
print('SECTION = "devel"')
|
|
|
|
print('LICENSE = "' + license + '"')
|
|
|
|
print('LIC_FILES_CHKSUM = "file://package.xml;beginline=' + license_line +
|
|
|
|
';endline=' + license_line + ';md5=' + license_md5 + '"')
|
|
|
|
if depends:
|
|
|
|
print('')
|
|
|
|
print('DEPENDS = "' + ' '.join(depends) + '"')
|
|
|
|
print('')
|
|
|
|
print('SRC_URI = ";downloadfilename=${P}.tar.gz"')
|
|
|
|
print('SRC_URI[md5sum] = ""')
|
|
|
|
print('SRC_URI[sha256sum] = ""')
|
|
|
|
print('')
|
|
|
|
print('S = "${WORKDIR}/-${PV}"')
|
|
|
|
print('')
|
|
|
|
if buildtools:
|
|
|
|
print('inherit ' + ' '.join(buildtools))
|
2013-02-08 21:02:56 +08:00
|
|
|
|