Beispiel #1
0
def _gen_recipe_for_package(distro, pkg_name, pkg, repo, ros_pkg,
                            pkg_rosinstall, tar_dir, md5_cache, sha256_cache,
                            patches, incs):
    pkg_dep_walker = DependencyWalker(distro)
    pkg_buildtool_deps = pkg_dep_walker.get_depends(pkg_name, "buildtool")
    pkg_build_deps = pkg_dep_walker.get_depends(pkg_name, "build")
    pkg_run_deps = pkg_dep_walker.get_depends(pkg_name, "run")
    src_uri = pkg_rosinstall[0]['tar']['uri']

    pkg_recipe = yoctoRecipe(pkg_name, distro, src_uri, tar_dir, md5_cache,
                             sha256_cache, patches, incs)
    # add run dependencies
    for rdep in pkg_run_deps:
        pkg_recipe.add_depend(rdep)

    # add build dependencies
    for bdep in pkg_build_deps:
        pkg_recipe.add_depend(bdep)

    # add build tool dependencies
    for tdep in pkg_buildtool_deps:
        pkg_recipe.add_depend(tdep)

    # parse throught package xml
    try:
        pkg_xml = ros_pkg.get_package_xml(distro.name)
    except Exception as e:
        warn("fetch metadata for package {}".format(pkg_name))
        return pkg_recipe
    pkg_fields = PackageMetadata(pkg_xml)
    pkg_recipe.pkg_xml = pkg_xml
    pkg_recipe.license = pkg_fields.upstream_license
    pkg_recipe.description = pkg_fields.description
    pkg_recipe.homepage = pkg_fields.homepage
    return pkg_recipe
 def test_no_homepage(self):
     """Test Package Metadata parsing without a homepage field"""
     with open('tests/PackageXml/test2.xml', 'r') as test_file:
         test_xml = test_file.read()
     ret = PackageMetadata(test_xml)
     self.assertEqual(ret.homepage,
                      'http://www.github.com/my_org/my_package')
Beispiel #3
0
 def __init__(self, component_name, num_pkgs, pkg_name, pkg_xml, distro,
              src_uri, tar_dir, md5_cache, sha256_cache, skip_keys):
     self.component = component_name
     yoctoRecipe.max_component_name = max(yoctoRecipe.max_component_name,
                                          len(component_name))
     self.oe_component = yoctoRecipe.convert_to_oe_name(component_name)
     self.num_pkgs = num_pkgs
     self.name = pkg_name
     self.distro = distro.name
     self.version = get_pkg_version(distro, pkg_name, is_oe=True)
     self.src_uri = src_uri
     self.pkg_xml = pkg_xml
     self.author = None
     if self.pkg_xml:
         pkg_fields = PackageMetadata(pkg_xml)
         maintainer_name = pkg_fields.upstream_name
         maintainer_email = pkg_fields.upstream_email
         author_name = pkg_fields.author_name
         author_email = pkg_fields.author_email
         self.maintainer = maintainer_name + ' <' + maintainer_email + '>'
         if author_name or author_email:
             self.author = author_name + \
                 (' <' + author_email + '>' if author_email else '')
         self.license = pkg_fields.upstream_license
         self.description = pkg_fields.description
         self.homepage = pkg_fields.homepage
         self.build_type = pkg_fields.build_type
     else:
         self.description = ''
         self.license = None
         self.homepage = None
         self.build_type = 'catkin'
         self.maintainer = "OSRF"
     self.depends = set()
     self.depends_external = set()
     self.buildtool_depends = set()
     self.buildtool_depends_external = set()
     self.export_depends = set()
     self.export_depends_external = set()
     self.buildtool_export_depends = set()
     self.buildtool_export_depends_external = set()
     self.rdepends = set()
     self.rdepends_external = set()
     self.tdepends = set()
     self.tdepends_external = set()
     self.license_line = None
     self.archive_name = None
     self.license_md5 = None
     self.tar_dir = tar_dir
     if self.getArchiveName() not in md5_cache or \
        self.getArchiveName() not in sha256_cache:
         self.downloadArchive()
         md5_cache[self.getArchiveName()] = hashlib.md5(
             open(self.getArchiveName(), 'rb').read()).hexdigest()
         sha256_cache[self.getArchiveName()] = hashlib.sha256(
             open(self.getArchiveName(), 'rb').read()).hexdigest()
     self.src_sha256 = sha256_cache[self.getArchiveName()]
     self.src_md5 = md5_cache[self.getArchiveName()]
     self.skip_keys = skip_keys
     self.multi_hyphen_re = re.compile('-{2,}')
Beispiel #4
0
 def __init__(
     self, component_name, num_pkgs, pkg_name, pkg_xml, distro, src_uri,
     srcrev_cache, skip_keys
 ):
     self.component = component_name
     yoctoRecipe.max_component_name = max(
         yoctoRecipe.max_component_name, len(component_name))
     self.oe_component = yoctoRecipe.convert_to_oe_name(component_name)
     self.num_pkgs = num_pkgs
     self.name = pkg_name
     self.distro = distro.name
     self.version = get_pkg_version(distro, pkg_name, is_oe=True)
     self.src_uri = src_uri
     self.pkg_xml = pkg_xml
     self.author = None
     if self.pkg_xml:
         pkg_fields = PackageMetadata(pkg_xml)
         maintainer_name = pkg_fields.upstream_name
         maintainer_email = pkg_fields.upstream_email
         author_name = pkg_fields.author_name
         author_email = pkg_fields.author_email
         self.maintainer = maintainer_name + ' <' + maintainer_email + '>'
         if author_name or author_email:
             self.author = author_name + \
                 (' <' + author_email + '>' if author_email else '')
         self.license = pkg_fields.upstream_license
         self.description = pkg_fields.description
         self.homepage = pkg_fields.homepage
         self.build_type = pkg_fields.build_type
     else:
         self.description = ''
         self.license = None
         self.homepage = None
         self.build_type = 'catkin' if \
             yoctoRecipe._get_ros_version(distro) == 1 else 'ament_cmake'
         self.maintainer = "OSRF"
     self.depends = set()
     self.depends_external = set()
     self.buildtool_depends = set()
     self.buildtool_depends_external = set()
     self.export_depends = set()
     self.export_depends_external = set()
     self.buildtool_export_depends = set()
     self.buildtool_export_depends_external = set()
     self.rdepends = set()
     self.rdepends_external = set()
     self.tdepends = set()
     self.tdepends_external = set()
     self.license_line = None
     self.license_md5 = None
     if self.src_uri not in srcrev_cache:
         srcrev_cache[self.src_uri] = self.get_srcrev()
     self.srcrev = srcrev_cache[self.src_uri]
     self.skip_keys = skip_keys
     self.multi_hyphen_re = re.compile('-{2,}')
 def test_metadata(self):
     """Test the Package Metadata parsing"""
     with open('tests/PackageXml/test.xml', 'r') as test_file:
         test_xml = test_file.read()
     ret = PackageMetadata(test_xml)
     self.assertEqual(ret.upstream_email, '*****@*****.**')
     self.assertEqual(ret.upstream_name, 'Someone')
     self.assertEqual(ret.description, 'This is my package\'s description.')
     self.assertEqual(ret.longdescription,
                      'This is my package\'s description.')
     self.assertEqual(ret.homepage, 'http://wiki.ros.org/my_package')
     self.assertEqual(ret.build_type, 'my_builder')
Beispiel #6
0
def _gen_ebuild_for_package(
    distro, pkg_name, pkg, repo, ros_pkg, pkg_rosinstall
):
    pkg_ebuild = Ebuild()

    pkg_ebuild.distro = distro.name
    pkg_ebuild.src_uri = pkg_rosinstall[0]['tar']['uri']
    pkg_names = get_package_names(distro)
    pkg_dep_walker = DependencyWalker(distro)

    pkg_buildtool_deps = pkg_dep_walker.get_depends(pkg_name, "buildtool")
    pkg_build_deps = pkg_dep_walker.get_depends(pkg_name, "build")
    pkg_run_deps = pkg_dep_walker.get_depends(pkg_name, "run")
    pkg_test_deps = pkg_dep_walker.get_depends(pkg_name, "test")

    pkg_keywords = ['x86', 'amd64', 'arm', 'arm64']

    # add run dependencies
    for rdep in pkg_run_deps:
        pkg_ebuild.add_run_depend(rdep, rdep in pkg_names[0])

    # add build dependencies
    for bdep in pkg_build_deps:
        pkg_ebuild.add_build_depend(bdep, bdep in pkg_names[0])

    # add build tool dependencies
    for tdep in pkg_buildtool_deps:
        pkg_ebuild.add_build_depend(tdep, tdep in pkg_names[0])

    # add test dependencies
    for test_dep in pkg_test_deps:
        pkg_ebuild.add_test_depend(test_dep, test_dep in pkg_names[0])

    # add keywords
    for key in pkg_keywords:
        pkg_ebuild.add_keyword(key)

    # parse throught package xml
    try:
        pkg_xml = ros_pkg.get_package_xml(distro.name)
    except Exception:
        warn("fetch metadata for package {}".format(pkg_name))
        return pkg_ebuild
    pkg = PackageMetadata(pkg_xml)
    pkg_ebuild.upstream_license = pkg.upstream_license
    pkg_ebuild.description = pkg.description
    pkg_ebuild.homepage = pkg.homepage
    pkg_ebuild.build_type = pkg.build_type
    return pkg_ebuild
Beispiel #7
0
def _gen_metadata_for_package(distro, pkg_name, pkg, repo, ros_pkg,
                              pkg_rosinstall):
    pkg_metadata_xml = metadata_xml()
    try:
        pkg_xml = retry_on_exception(ros_pkg.get_package_xml, distro.name)
    except Exception:
        warn("fetch metadata for package {}".format(pkg_name))
        return pkg_metadata_xml
    pkg = PackageMetadata(pkg_xml)
    pkg_metadata_xml.upstream_email = pkg.upstream_email
    pkg_metadata_xml.upstream_name = pkg.upstream_name
    pkg_metadata_xml.longdescription = pkg.longdescription
    pkg_metadata_xml.upstream_bug_url =\
        repo.url.replace("-release", "").replace(".git", "/issues")
    return pkg_metadata_xml
Beispiel #8
0
 def __init__(
     self, component_name, num_pkgs, pkg_name, pkg_xml, rosdistro, src_uri,
     srcrev_cache, skip_keys
 ):
     self.component = component_name
     yoctoRecipe.max_component_name = max(
         yoctoRecipe.max_component_name, len(component_name))
     self.oe_component = yoctoRecipe.convert_to_oe_name(component_name)
     self.num_pkgs = num_pkgs
     self.name = pkg_name
     self.distro = rosdistro.name
     self.version = get_pkg_version(rosdistro, pkg_name, is_oe=True)
     self.src_uri = src_uri
     self.pkg_xml = pkg_xml
     self.author = None
     if self.pkg_xml:
         pkg_fields = PackageMetadata(
             pkg_xml,
             yoctoRecipe._get_condition_context(rosdistro.name))
         maintainer_name = pkg_fields.upstream_name
         maintainer_email = pkg_fields.upstream_email
         author_name = pkg_fields.author_name
         author_email = pkg_fields.author_email
         self.maintainer = maintainer_name + ' <' + maintainer_email + '>'
         if author_name or author_email:
             self.author = author_name + \
                 (' <' + author_email + '>' if author_email else '')
         self.license = pkg_fields.upstream_license
         self.description = pkg_fields.description
         self.homepage = pkg_fields.homepage
         pkg_build_type = pkg_fields.build_type
         if pkg_build_type == 'catkin' and \
            yoctoRecipe._get_ros_version(rosdistro.name) == 2:
             err("Package " + pkg_name + " either doesn't have <export>"
                 "<build_type> element at all or it's set to 'catkin'"
                 " which isn't a valid option for ROS 2; changing it to"
                 " 'ament_cmake'")
             pkg_build_type = 'ament_cmake'
         self.build_type = pkg_build_type
     else:
         self.description = ''
         self.license = None
         self.homepage = None
         self.build_type = 'catkin' if \
             yoctoRecipe._get_ros_version(rosdistro.name) == 1 \
             else 'ament_cmake'
         self.maintainer = "OSRF"
     self.depends = set()
     self.depends_external = set()
     self.buildtool_depends = set()
     self.buildtool_depends_external = set()
     self.export_depends = set()
     self.export_depends_external = set()
     self.buildtool_export_depends = set()
     self.buildtool_export_depends_external = set()
     self.rdepends = set()
     self.rdepends_external = set()
     self.tdepends = set()
     self.tdepends_external = set()
     self.license_line = None
     self.license_md5 = None
     if self.src_uri not in srcrev_cache:
         srcrev_cache[self.src_uri] = self.get_srcrev()
     self.srcrev = srcrev_cache[self.src_uri]
     self.skip_keys = skip_keys