create-recipe.py: direct read package.xml file
Signed-off-by: Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net>
This commit is contained in:
parent
6db31c7221
commit
e9233125c0
|
@ -1,45 +1,71 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2013 Lukas Bulwahn, BMW Car IT GmbH
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
# Copyright (c) 2013 Stefan Herbrechtsmeier, Bielefeld University
|
||||
#
|
||||
|
||||
info = {'description' : '',
|
||||
'license' : '', 'lic_file_beginline' : '', 'lic_file_endline' : '', 'lic_file_md5' : '',
|
||||
'url' : '', 'downloadfilename' : '', 'md5sum' : '', 'sha256sum' : '', 'directoryname' : ''}
|
||||
import sys
|
||||
import os
|
||||
import xml.etree.ElementTree as ElementTree
|
||||
import hashlib
|
||||
|
||||
print '''DESCRIPTION = "%(description)s"
|
||||
SECTION = "devel"
|
||||
LICENSE = "%(license)s"
|
||||
LIC_FILES_CHKSUM = "file://package.xml;beginline=%(lic_file_beginline)s;endline=%(lic_file_endline)s;md5=%(lic_file_md5)s"
|
||||
filename = 'package.xml'
|
||||
|
||||
SRC_URI = "%(url)s;downloadfilename=%(downloadfilename)s"
|
||||
SRC_URI[md5sum] = "%(md5sum)s"
|
||||
SRC_URI[sha256sum] = "%(sha256sum)s"
|
||||
if len(sys.argv) > 1:
|
||||
filename = sys.argv[1]
|
||||
|
||||
S = "${WORKDIR}/%(directoryname)s"
|
||||
if not os.path.isfile(filename):
|
||||
exit(-1)
|
||||
|
||||
DEPENDS = "catkin-native"
|
||||
tree = ElementTree.parse(filename)
|
||||
root = tree.getroot()
|
||||
|
||||
inherit cmake pythonnative
|
||||
name = tree.findtext('name', '')
|
||||
version = tree.findtext('version', '')
|
||||
description = tree.findtext('description', '').strip()
|
||||
license = tree.findtext('license', '')
|
||||
homepage = tree.findtext('url', '')
|
||||
|
||||
''' % info
|
||||
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
|
||||
|
||||
|
||||
buildtools = []
|
||||
for e in root.findall('buildtool_depend'):
|
||||
buildtools.append(e.text)
|
||||
|
||||
depends = []
|
||||
for e in root.findall('build_depend'):
|
||||
depends.append(e.text.replace('_', '-'))
|
||||
|
||||
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))
|
||||
|
||||
|
|
Loading…
Reference in New Issue