Beispiel #1
0
 def test_get_license(self):
     """Test license recognition function"""
     ret = get_license('Apache License 2.0')
     self.assertEqual(ret, 'Apache-2.0')
     ret = get_license('Apache 2.0')
     self.assertEqual(ret, 'Apache-2.0')
     ret = get_license(
         'Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
     )
     self.assertEqual(ret, 'Apache-2.0')
     ret = get_license('BSD-3')
     self.assertEqual(ret, 'BSD')
     ret = get_license('Apache-2')
     self.assertEqual(ret, 'Apache-2.0')
     ret = get_license(
         'CreativeCommons-Attribution-NonCommercial-NoDerivatives-4.0')
     self.assertEqual(ret, 'CC-BY-NC-ND-4.0')
     ret = get_license('CC BY-NC-SA 4.0')
     self.assertEqual(ret, 'CC-BY-NC-SA-4.0')
     ret = get_license('BoostSoftwareLicense Version1.0')
     self.assertEqual(ret, 'Boost-1.0')
     ret = get_license('GNU GPLv3')
     self.assertEqual(ret, 'GPL-3')
     ret = get_license('Public Domain')
     self.assertEqual(ret, 'public_domain')
Beispiel #2
0
    def get_recipe_text(self, distributor, license_text, die_msg=None):
        """
        Generate the Yocto Recipe, given the distributor line
        and the license text.
        """
        ret = "# Copyright " + strftime("%Y", gmtime()) + " "
        ret += distributor + "\n"
        ret += '# Distributed under the terms of the ' + license_text
        ret += ' license\n\n'

        # description
        if self.description:
            self.description = self.description.replace('\n', ' ')
            ret += 'DESCRIPTION = "' + self.description + '"\n'
        else:
            ret += 'DESCRIPTION = "None"\n'
        # author
        ret += 'AUTHOR = "' + self.author + '"\n'
        # section
        ret += 'SECTION = "devel"\n'
        self.get_license_line()
        if isinstance(self.license, str):
            ret += 'LICENSE = "%s"\n' % get_license(self.license)
        elif isinstance(self.license, list):
            ret += 'LICENSE = "'
            ret += ' & '.join([get_license(l) for l in self.license]) + '"\n'
        ret += 'LIC_FILES_CHKSUM = "file://package.xml;beginline='
        ret += str(self.license_line)
        ret += ';endline='
        ret += str(self.license_line)
        ret += ';md5='
        ret += str(self.license_md5)
        ret += '"\n\n'

        # DEPEND
        first = True
        ret += 'DEPENDS = "'
        for dep in sorted(self.depends):
            if not first:
                ret += ' '
            ret += resolve_dep(dep, 'oe')
            first = False
        ret += '"\n'

        # SRC_URI
        self.src_uri = self.src_uri.replace(self.name, '${PN}')
        ret += 'SRC_URI = "' + self.src_uri + ';'
        ret += 'downloadfilename=${ROS_SP}.tar.gz"\n\n'
        ret += 'SRC_URI[md5sum] = "' + self.src_md5 + '"\n'
        ret += 'SRC_URI[sha256sum] = "' + self.src_sha256 + '"\n'
        ret += 'S = "${WORKDIR}/'
        ret += self.get_src_location() + '"\n\n'
        ret += 'inherit catkin\n'
        return ret
Beispiel #3
0
 def test_get_license(self):
     """Test license recognition function"""
     ret = get_license('Apache License 2.0')
     self.assertEqual(ret, 'Apache-2.0')
     ret = get_license('Apache 2.0')
     self.assertEqual(ret, 'Apache-2.0')
     ret = get_license('Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)')
     self.assertEqual(ret, 'Apache-2.0')
     ret = get_license('Apache')
     self.assertEqual(ret, 'Apache')
     ret = get_license('BSD-3')
     self.assertEqual(ret, 'BSD-3-Clause')
     ret = get_license('Apache2')
     self.assertEqual(ret, 'Apache-2.0')
     ret = get_license('CreativeCommons-Attribution-NonCommercial-NoDerivatives-4.0')
     self.assertEqual(ret, 'CC-BY-NC-ND-4.0')
     ret = get_license('CC BY-NC-SA 4.0')
     self.assertEqual(ret, 'CC-BY-NC-SA-4.0')
     ret = get_license('Boost Software License, Version 1.0')
     self.assertEqual(ret, 'BSL-1.0')
     ret = get_license('GNU GPL v3.0')
     self.assertEqual(ret, 'GPL-3.0-only')
     ret = get_license('Public Domain')
     self.assertEqual(ret, 'PD')
     ret = get_license('GPL')
     self.assertEqual(ret, 'GPL')
     ret = get_license('GNU General Public License v2.0')
     self.assertEqual(ret, 'GPL-2.0-only')
     ret = get_license('GNU Lesser Public License 2.1')
     self.assertEqual(ret, 'LGPL-2.1-only')
     ret = get_license('Mozilla Public License Version 1.1')
     self.assertEqual(ret, 'MPL-1.1')
     ret = get_license('Mozilla Public License')
     self.assertEqual(ret, 'Mozilla-Public-License')
     ret = get_license('BSD License 2.0')
     self.assertEqual(ret, 'BSD-License-2.0')
     ret = get_license('MIT')
     self.assertEqual(ret, 'MIT')
     ret = get_license('Creative Commons')
     self.assertEqual(ret, 'Creative-Commons')
     ret = get_license('United States Government Purpose')
     self.assertEqual(ret, 'United-States-Government-Purpose')
Beispiel #4
0
 def get_recipe_text(self, distributor):
     """
     Generate the Yocto Recipe, given the distributor line
     and the license text.
     """
     ret = "# Generated by superflore -- DO NOT EDIT\n#\n"
     ret += "# Copyright " + distributor + "\n\n"
     ret += self.get_top_inherit_line()
     # description
     if self.description:
         self.description = self.description.replace('\n', ' ')
         ret += 'DESCRIPTION = "' + self.description + '"\n'
     else:
         ret += 'DESCRIPTION = "None"\n'
     # author
     ret += 'AUTHOR = "' + self.maintainer + '"\n'
     if self.author:
         ret += 'ROS_AUTHOR = "' + self.author + '"\n'
     if self.homepage:
         ret += 'HOMEPAGE = "' + self.homepage + '"\n'
     # section
     ret += 'SECTION = "devel"\n'
     # license
     self.get_license_line()
     if isinstance(self.license, str):
         ret += 'LICENSE = "%s"\n' % self.translate_license(
             get_license(self.license))
     elif isinstance(self.license, list):
         ret += 'LICENSE = "'
         ret += ' & '.join(
             [self.translate_license(get_license(l))
              for l in self.license]) + '"\n'
     ret += 'LIC_FILES_CHKSUM = "file://package.xml;beginline='
     ret += str(self.license_line)
     ret += ';endline='
     ret += str(self.license_line)
     ret += ';md5='
     ret += str(self.license_md5)
     ret += '"\n\n'
     ret += 'ROS_CN = "' + self.component + '"\n'
     ret += 'ROS_BPN = "' + self.name + '"\n\n'
     # depends
     deps, sys_deps = self.get_dependencies(self.depends,
                                            self.depends_external)
     yoctoRecipe.platform_deps |= sys_deps
     buildtool_native_deps, sys_deps = self.get_dependencies(
         self.buildtool_depends,
         self.buildtool_depends_external,
         is_native=True)
     native_deps = set(buildtool_native_deps)
     yoctoRecipe.platform_deps |= sys_deps
     export_deps, sys_deps = self.get_dependencies(
         self.export_depends, self.export_depends_external)
     yoctoRecipe.platform_deps |= sys_deps
     buildtool_export_native_deps, sys_deps = self.get_dependencies(
         self.buildtool_export_depends,
         self.buildtool_export_depends_external,
         is_native=True)
     native_deps |= buildtool_export_native_deps
     yoctoRecipe.platform_deps |= sys_deps
     yoctoRecipe.generated_native_recipes |= native_deps
     exec_deps, sys_deps = self.get_dependencies(self.rdepends,
                                                 self.rdepends_external)
     yoctoRecipe.platform_deps |= sys_deps
     test_deps, sys_deps = self.get_dependencies(self.tdepends,
                                                 self.tdepends_external)
     yoctoRecipe.platform_deps |= sys_deps
     yoctoRecipe.generated_non_test_deps |= deps | export_deps | \
         native_deps | exec_deps
     yoctoRecipe.generated_test_deps |= test_deps
     ret += yoctoRecipe.generate_multiline_variable('ROS_BUILD_DEPENDS',
                                                    deps) + '\n'
     ret += yoctoRecipe.generate_multiline_variable(
         'ROS_BUILDTOOL_DEPENDS', buildtool_native_deps) + '\n'
     if self.name == 'ament_cmake':
         ret += yoctoRecipe.generate_multiline_variable(
             'ROS_EXPORT_DEPENDS', '') + '\n'
         ament_cmake_native_deps, sys_deps = self.get_dependencies(
             self.export_depends,
             self.export_depends_external,
             is_native=True)
         buildtool_export_native_deps |= ament_cmake_native_deps
         yoctoRecipe.generated_non_test_deps |= ament_cmake_native_deps
         yoctoRecipe.generated_native_recipes |= ament_cmake_native_deps
         yoctoRecipe.platform_deps |= sys_deps
     else:
         ret += yoctoRecipe.generate_multiline_variable(
             'ROS_EXPORT_DEPENDS', export_deps) + '\n'
     ret += yoctoRecipe.generate_multiline_variable(
         'ROS_BUILDTOOL_EXPORT_DEPENDS',
         buildtool_export_native_deps) + '\n'
     ret += yoctoRecipe.generate_multiline_variable('ROS_EXEC_DEPENDS',
                                                    exec_deps) + '\n'
     ret += '# Currently informational only -- see '
     ret += 'http://www.ros.org/reps/rep-0149.html#dependency-tags.\n'
     ret += yoctoRecipe.generate_multiline_variable('ROS_TEST_DEPENDS',
                                                    test_deps) + '\n'
     ret += 'DEPENDS = "${ROS_BUILD_DEPENDS} ${ROS_BUILDTOOL_DEPENDS}"\n'
     ret += '# Bitbake doesn\'t support the "export" concept, so build them'
     ret += ' as if we needed them to build this package (even though we'
     ret += ' actually\n# don\'t) so that they\'re guaranteed to have been'
     ret += ' staged should this package appear in another\'s DEPENDS.\n'
     ret += 'DEPENDS += "${ROS_EXPORT_DEPENDS} '
     ret += '${ROS_BUILDTOOL_EXPORT_DEPENDS}"\n\n'
     ret += 'RDEPENDS_${PN} += "${ROS_EXEC_DEPENDS}"' + '\n\n'
     # SRC_URI
     ret += '# matches with: ' + self.src_uri + '\n'
     ret += 'ROS_BRANCH ?= "branch=' + self.get_repo_branch_name() + '"\n'
     ret += 'SRC_URI = "git://' + self.get_repo_src_uri() + \
         ';${ROS_BRANCH};protocol=https"\n'
     ret += 'SRCREV = "' + self.srcrev + '"\n'
     ret += 'S = "${WORKDIR}/git"\n\n'
     ret += 'ROS_BUILD_TYPE = "' + self.build_type + '"\n'
     # Inherits
     ret += '\n' + self.get_bottom_inherit_line()
     return ret
Beispiel #5
0
 def test_get_license(self):
     """Test license recognition function"""
     ret = get_license('Apache License 2.0')
     self.assertEqual(ret, 'Apache-2.0')
     ret = get_license('Apache 2.0')
     self.assertEqual(ret, 'Apache-2.0')
     ret = get_license(
         'Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)'
     )
     self.assertEqual(ret, 'Apache-2.0')
     ret = get_license('Apache')
     self.assertEqual(ret, 'Apache-1.0')
     ret = get_license('BSD-3')
     self.assertEqual(ret, 'BSD')
     ret = get_license('Apache-2')
     self.assertEqual(ret, 'Apache-2.0')
     ret = get_license(
         'CreativeCommons-Attribution-NonCommercial-NoDerivatives-4.0')
     self.assertEqual(ret, 'CC-BY-NC-ND-4.0')
     ret = get_license('CC BY-NC-SA 4.0')
     self.assertEqual(ret, 'CC-BY-NC-SA-4.0')
     ret = get_license('BoostSoftwareLicense Version1.0')
     self.assertEqual(ret, 'Boost-1.0')
     ret = get_license('GNU GPLv3')
     self.assertEqual(ret, 'GPL-3')
     ret = get_license('Public Domain')
     self.assertEqual(ret, 'public_domain')
     ret = get_license('GPL')
     self.assertEqual(ret, 'GPL-1')
     ret = get_license('GNU GENERAL PUBLIC LICENSE Version 3')
     self.assertEqual(ret, 'GPL-3')
     ret = get_license('GNU Lesser Public License 2.1')
     self.assertEqual(ret, 'LGPL-2.1')
     ret = get_license('Mozilla Public License Version 1.1')
     self.assertEqual(ret, 'MPL-1.1')
     ret = get_license('Mozilla Public License')
     self.assertEqual(ret, 'MPL-2.0')
     ret = get_license('BSD License 2.0')
     self.assertEqual(ret, 'BSD-2')
     ret = get_license('MIT')
     self.assertEqual(ret, 'MIT')
     ret = get_license('Creative Commons')
     self.assertEqual(ret, 'CC-BY-SA-3.0')
     with self.assertRaises(UnknownLicense):
         ret = get_license('TODO')
Beispiel #6
0
 def get_recipe_text(self, distributor):
     """
     Generate the Yocto Recipe, given the distributor line
     and the license text.
     """
     ret = "# Generated by superflore -- DO NOT EDIT\n#\n"
     ret += "# Copyright " + strftime("%Y", gmtime()) + " "
     ret += distributor + "\n\n"
     ret += self.get_top_inherit_line()
     # description
     if self.description:
         self.description = self.description.replace('\n', ' ')
         ret += 'DESCRIPTION = "' + self.description + '"\n'
     else:
         ret += 'DESCRIPTION = "None"\n'
     # author
     ret += 'AUTHOR = "' + self.maintainer + '"\n'
     if self.author:
         ret += 'ROS_AUTHOR = "' + self.author + '"\n'
     if self.homepage:
         ret += 'HOMEPAGE = "' + self.homepage + '"\n'
     # section
     ret += 'SECTION = "devel"\n'
     # license
     self.get_license_line()
     if isinstance(self.license, str):
         ret += 'LICENSE = "%s"\n' % self.translate_license(
             get_license(self.license))
     elif isinstance(self.license, list):
         ret += 'LICENSE = "'
         ret += ' & '.join([self.translate_license(
             get_license(l)) for l in self.license]) + '"\n'
     ret += 'LIC_FILES_CHKSUM = "file://package.xml;beginline='
     ret += str(self.license_line)
     ret += ';endline='
     ret += str(self.license_line)
     ret += ';md5='
     ret += str(self.license_md5)
     ret += '"\n\n'
     ret += 'ROS_CN = "' + self.component + '"\n'
     ret += 'ROS_BPN = "' + self.name + '"\n\n'
     # depends
     deps, sys_deps = self.get_dependencies(
         self.depends, self.depends_external)
     yoctoRecipe.platform_deps |= sys_deps
     buildtool_native_deps, sys_deps = self.get_dependencies(
         self.buildtool_depends,
         self.buildtool_depends_external,
         is_native=True
     )
     native_deps = set(buildtool_native_deps)
     yoctoRecipe.platform_deps |= sys_deps
     export_deps, sys_deps = self.get_dependencies(
         self.export_depends, self.export_depends_external)
     yoctoRecipe.platform_deps |= sys_deps
     buildtool_export_native_deps, sys_deps = self.get_dependencies(
         self.buildtool_export_depends,
         self.buildtool_export_depends_external,
         is_native=True
     )
     native_deps |= buildtool_export_native_deps
     yoctoRecipe.platform_deps |= sys_deps
     yoctoRecipe.generated_native_recipes |= native_deps
     exec_deps, sys_deps = self.get_dependencies(
         self.rdepends, self.rdepends_external)
     yoctoRecipe.platform_deps |= sys_deps
     test_deps, sys_deps = self.get_dependencies(self.tdepends,
                                                 self.tdepends_external)
     yoctoRecipe.platform_deps |= sys_deps
     yoctoRecipe.generated_non_test_deps |= deps | export_deps | \
         native_deps | exec_deps
     yoctoRecipe.generated_test_deps |= test_deps
     ret += yoctoRecipe.generate_multiline_variable(
         'ROS_BUILD_DEPENDS', deps) + '\n'
     ret += yoctoRecipe.generate_multiline_variable(
         'ROS_BUILDTOOL_DEPENDS', buildtool_native_deps) + '\n'
     if self.name == 'ament_cmake':
         ret += yoctoRecipe.generate_multiline_variable(
             'ROS_EXPORT_DEPENDS', '') + '\n'
         ament_cmake_native_deps, sys_deps = self.get_dependencies(
             self.export_depends,
             self.export_depends_external,
             is_native=True
         )
         buildtool_export_native_deps |= ament_cmake_native_deps
         yoctoRecipe.generated_non_test_deps |= ament_cmake_native_deps
         yoctoRecipe.generated_native_recipes |= ament_cmake_native_deps
         yoctoRecipe.platform_deps |= sys_deps
     else:
         ret += yoctoRecipe.generate_multiline_variable(
             'ROS_EXPORT_DEPENDS', export_deps) + '\n'
     ret += yoctoRecipe.generate_multiline_variable(
         'ROS_BUILDTOOL_EXPORT_DEPENDS',
         buildtool_export_native_deps) + '\n'
     ret += yoctoRecipe.generate_multiline_variable(
         'ROS_EXEC_DEPENDS', exec_deps) + '\n'
     ret += '# Currently informational only -- see '
     ret += 'http://www.ros.org/reps/rep-0149.html#dependency-tags.\n'
     ret += yoctoRecipe.generate_multiline_variable(
         'ROS_TEST_DEPENDS', test_deps) + '\n'
     ret += 'DEPENDS = "${ROS_BUILD_DEPENDS} ${ROS_BUILDTOOL_DEPENDS}"\n'
     ret += '# Bitbake doesn\'t support the "export" concept, so build them'
     ret += ' as if we needed them to build this package (even though we'
     ret += ' actually\n# don\'t) so that they\'re guaranteed to have been'
     ret += ' staged should this package appear in another\'s DEPENDS.\n'
     ret += 'DEPENDS += "${ROS_EXPORT_DEPENDS} '
     ret += '${ROS_BUILDTOOL_EXPORT_DEPENDS}"\n\n'
     ret += 'RDEPENDS_${PN} += "${ROS_EXEC_DEPENDS}"' + '\n\n'
     # SRC_URI
     ret += 'SRC_URI = "' + self.src_uri + ';'
     ret += 'downloadfilename=${ROS_SP}.tar.gz"\n'
     ret += 'SRC_URI[md5sum] = "' + self.src_md5 + '"\n'
     ret += 'SRC_URI[sha256sum] = "' + self.src_sha256 + '"\n'
     ret += 'S = "${WORKDIR}/'
     ret += self.get_src_location() + '"\n\n'
     ret += 'ROS_COMPONENT_TYPE = "${@ros_distro__get_component_type(\''
     ret += self.oe_component + '\', d)}"\n'
     ret += 'ROS_BUILD_TYPE = "' + self.build_type + '"\n'
     # include
     ret += '\n# Allow the above settings to be overridden.\n'
     ret += 'ROS_INCLUDES_TREE := '
     ret += '"${@ros_superflore_generated__get_includes_tree(\''
     ret += self.oe_component + '\', d)}"\n'
     inc_prefix = 'include ${ROS_LAYERDIR}/'
     component_path = '/' + self.oe_component + '/' + self.oe_component
     inc_suffix = '_common.inc\n'
     ret += inc_prefix + '${ROS_INCLUDES_TREE}' + component_path + \
         inc_suffix
     ret += inc_prefix + '${ROS_INCLUDES_TREE}' + \
         component_path + '-${PV}' + inc_suffix
     path_prefix = inc_prefix + '${ROS_INCLUDES_TREE}/' + self.oe_component
     ret += path_prefix + '/${BPN}.inc\n'
     ret += path_prefix + '/${BPN}-${PV}.inc\n'
     # Inherits
     ret += '\n' + self.get_bottom_inherit_line()
     return ret
Beispiel #7
0
    def get_recipe_text(self, distributor, license_text):
        """
        Generate the Yocto Recipe, given the distributor line
        and the license text.
        """
        ret = "# Copyright " + strftime("%Y", gmtime()) + " "
        ret += distributor + "\n"
        ret += '# Distributed under the terms of the ' + license_text
        ret += ' license\n\n'

        # description
        if self.description:
            self.description = self.description.replace('\n', ' ')
            ret += 'DESCRIPTION = "' + self.description + '"\n'
        else:
            ret += 'DESCRIPTION = "None"\n'
        # author
        ret += 'AUTHOR = "' + self.author + '"\n'
        # section
        ret += 'SECTION = "devel"\n'
        # ROS distro
        ret += 'ROSDISTRO = "%s"\n' % (self.distro)
        self.get_license_line()
        if isinstance(self.license, str):
            ret += 'LICENSE = "%s"\n' % get_license(self.license)
        elif isinstance(self.license, list):
            ret += 'LICENSE = "'
            ret += ' & '.join([get_license(l) for l in self.license]) + '"\n'
        ret += 'LIC_FILES_CHKSUM = "file://package.xml;beginline='
        ret += str(self.license_line)
        ret += ';endline='
        ret += str(self.license_line)
        ret += ';md5='
        ret += str(self.license_md5)
        ret += '"\n\n'
        # check for catkin
        if self.name == 'catkin':
            ret += 'CATKIN_NO_BIN="True"\n\n'
        # DEPEND
        first = True
        ret += 'DEPENDS = "'
        for dep in sorted(self.depends):
            if not first:
                ret += ' '
            # TODO: pass self.distro to resolve_dep
            ret += resolve_dep(dep, 'gentoo', '2.4.0', self.distro)
            first = False
        ret += '"\n'

        # SRC_URI
        self.src_uri = self.src_uri.replace(self.name, '${PN}')
        ret += 'SRC_URI = "' + self.src_uri + ';'
        ret += 'downloadfilename=${ROS_SP}.tar.gz"\n\n'
        ret += 'SRC_URI[md5sum] = "' + self.src_md5 + '"\n'
        ret += 'SRC_URI[sha256sum] = "' + self.src_sha256 + '"\n'
        ret += 'S = "${WORKDIR}/'
        ret += self.get_src_location() + '"\n\n'
        # Check for patches
        if self.patch_files:
            ret += 'SRC_URI += "\\\n'
            ret += ' \\\n'.join(self.patch_files) + '"\n\n'
        if self.inc_files:
            self.inc_files = ['require %s' % f for f in self.inc_files]
            ret += '\n'.join(self.inc_files)
        ret += 'inherit catkin\n'
        return ret
Beispiel #8
0
    def get_ebuild_text(self, distributor, license_text):
        """
        Generate the ebuild in text, given the distributor line
        and the license text.
        """
        ret = "# Copyright " + strftime("%Y", gmtime()) + " "
        ret += distributor + "\n"
        ret += "# Distributed under the terms of the " + license_text
        ret += " license\n\n"

        # EAPI=<eapi>
        ret += "EAPI=" + self.eapi + "\n"
        if self.python_3:
            ret += "PYTHON_COMPAT=( python{2_7,3_5} )\n\n"
        else:
            ret += "PYTHON_COMPAT=( python2_7 )\n\n"
        # inherits
        ret += "inherit ros-cmake\n\n"

        # description, homepage, src_uri
        self.description =\
            sanitize_string(self.description, self.illegal_desc_chars)
        self.description = trim_string(self.description)
        ret += "DESCRIPTION=\"" + self.description + "\"\n"
        ret += "HOMEPAGE=\"" + self.homepage + "\"\n"
        self.src_uri = self.src_uri.replace(self.name, '${PN}')
        ret += "SRC_URI=\"" + self.src_uri
        ret += " -> ${PN}-" + self.distro + "-release-${PV}.tar.gz\"\n\n"
        # license -- only add if valid
        if isinstance(self.upstream_license, str):
            split = self.upstream_license.split(',')
            if len(split) > 1:
                # they did something like "BSD,GPL,blah"
                ret += 'LICENSE="( '
                ret += ' '.join([get_license(l) for l in split])
                ret += ') "\n'
            else:
                ret += "LICENSE=\""
                ret += get_license(self.upstream_license) + "\"\n\n"
        elif isinstance(self.upstream_license, list):
            ret += "LICENSE=\"( "
            ret += ' '.join([get_license(ul) for ul in self.upstream_license])
            ret += " )\"\n"
        # iterate through the keywords, adding to the KEYWORDS line.
        ret += "KEYWORDS=\""
        ret += ' '.join([key.to_string() for key in self.keys])
        ret += "\"\n"
        # RDEPEND
        ret += "RDEPEND=\"\n"
        for rdep in sorted(self.rdepends):
            ret += "    " + "ros-" + self.distro + "/" + rdep + "\n"
        for rdep in sorted(self.rdepends_external):
            try:
                for res in resolve_dep(rdep, 'gentoo')[0]:
                    if res in depend_only_pkgs:
                        self.depends_external.append(rdep)
                        break
                    else:
                        ret += "    " + res + "\n"
            except UnresolvedDependency:
                self.unresolved_deps.append(rdep)

        ret += "\"\n"

        # DEPEND
        ret += "DEPEND=\"${RDEPEND}\n"
        for bdep in sorted(self.depends):
            ret += "    " + 'ros-{0}/{1}\n'.format(self.distro, bdep)
        for bdep in sorted(self.depends_external):
            try:
                for res in resolve_dep(bdep, 'gentoo')[0]:
                    ret += "    " + res + "\n"
            except UnresolvedDependency:
                self.unresolved_deps.append(bdep)
        ret += "\"\n\n"

        # SLOT
        ret += "SLOT=\"0\"\n"
        # CMAKE_BUILD_TYPE
        if self.name == "catkin":
            ret += "BUILD_BINARY=\"0\"\n"
        ret += "ROS_DISTRO=\"{0}\"\n".format(self.distro)
        ret += "ROS_PREFIX=\"opt/ros/${ROS_DISTRO}\"\n"

        # Patch source if needed.
        if self.has_patches:
            ret += "\nsrc_prepare() {\n"
            ret += "    cd ${P}\n"
            ret += "    EPATCH_SOURCE=\"${FILESDIR}\""
            ret += " EPATCH_SUFFIX=\"patch\" \\\n"
            ret += "    EPATCH_FORCE=\"yes\" epatch\n"
            ret += "    ros-cmake_src_prepare\n"
            ret += "}\n"

        special_pkgs = ['opencv3', 'stage']
        # source configuration
        if self.name in special_pkgs:
            ret += "\nsrc_configure() {\n"
            if self.name == 'opencv3':
                ret += "    filter-flags '-march=*' '-mcpu=*' '-mtune=*'\n"
            elif self.name == 'stage':
                ret += "    filter-flags '-std=*'\n"
            ret += "    ros-cmake_src_configure\n"
            ret += "}\n"

        if len(self.unresolved_deps) > 0:
            raise UnresolvedDependency("failed to satisfy dependencies!")

        return ret.replace('    ', '\t')
Beispiel #9
0
    def get_ebuild_text(self, distributor, license_text):
        """
        Generate the ebuild in text, given the distributor line
        and the license text.
        """
        # EAPI=<eapi>
        ret = self.get_license_line(distributor, license_text)
        ret += self.get_eapi_line()
        if self.python_3 and not self.is_ros2:
            # enable python 2.7 and python 3.5
            ret += self.get_python_compat(['2_7', '3_5'])
        elif self.python_3:
            # only use 3.5, 3.6 for ROS 2
            ret += self.get_python_compat(['3_5', '3_6'])
        else:
            # fallback to python 2.7
            ret += self.get_python_compat(['2_7'])
        # inherits
        ret += self.get_inherit_line()
        # description, homepage, src_uri
        self.description =\
            sanitize_string(self.description, self.illegal_desc_chars)
        self.description = trim_string(self.description)
        ret += "DESCRIPTION=\"" + self.description + "\"\n"
        ret += "HOMEPAGE=\"" + self.homepage + "\"\n"
        self.src_uri = self.src_uri.replace(self.name, '${PN}')
        ret += "SRC_URI=\"" + self.src_uri
        ret += " -> ${PN}-" + self.distro + "-release-${PV}.tar.gz\"\n\n"
        # license -- only add if valid
        if len(self.upstream_license) == 1:
            self.upstream_license = [
                l.replace(', ', ' ') for l in self.upstream_license
            ]
            split = self.upstream_license[0].split(',')
            if len(split) > 1:
                # they did something like "BSD,GPL,blah"
                ret += 'LICENSE="( '
                ret += ' '.join([get_license(l.strip()) for l in split])
                ret += ' )"\n'
            else:
                ret += "LICENSE=\""
                ret += get_license(self.upstream_license[0]) + "\"\n\n"
        else:
            ret += "LICENSE=\"( "
            ret += ' '.join(
                [get_license(ul) for ul in self.upstream_license]
            )
            ret += " )\"\n"
        # iterate through the keywords, adding to the KEYWORDS line.
        ret += "KEYWORDS=\""
        ret += ' '.join([key.to_string() for key in self.keys])
        ret += "\"\n"
        if len(self.tdepends) or len(self.tdepends_external):
            ret += 'IUSE="test"\n'
        # RDEPEND
        ret += "RDEPEND=\"\n"
        for rdep in sorted(self.rdepends):
            ret += "    " + "ros-" + self.distro + "/" + rdep + "\n"
        # internal test dependencies
        for tdep in sorted(self.tdepends):
            ret += "    " + "test? ( ros-" + self.distro + "/" + tdep + " )\n"
        for rdep in sorted(self.rdepends_external):
            try:
                for res in resolve_dep(rdep, 'gentoo')[0]:
                    if res in depend_only_pkgs:
                        self.depends_external.append(rdep)
                        break
                    else:
                        ret += "    " + res + "\n"
            except UnresolvedDependency:
                self.unresolved_deps.append(rdep)
        # external test dependencies
        for tdep in sorted(self.tdepends_external):
            try:
                for res in resolve_dep(tdep, 'gentoo')[0]:
                    ret += "    test? ( " + res + " )\n"
            except UnresolvedDependency:
                self.unresolved_deps.append(tdep)
        ret += "\"\n"
        # DEPEND
        ret += "DEPEND=\"${RDEPEND}\n"
        for bdep in sorted(self.depends):
            ret += "    " + 'ros-{0}/{1}\n'.format(self.distro, bdep)
        for bdep in sorted(self.depends_external):
            try:
                for res in resolve_dep(bdep, 'gentoo')[0]:
                    ret += "    " + res + "\n"
            except UnresolvedDependency:
                self.unresolved_deps.append(bdep)
        ret += "\"\n\n"

        # SLOT
        ret += "SLOT=\"0\"\n"
        # CMAKE_BUILD_TYPE
        if self.name == "catkin":
            ret += "BUILD_BINARY=\"0\"\n"
        ret += "ROS_DISTRO=\"{0}\"\n".format(self.distro)
        ret += "ROS_PREFIX=\"opt/ros/${ROS_DISTRO}\"\n"

        # Patch source if needed.
        if self.has_patches:
            # TODO(allenh1): explicitly list patches
            ret += "\nsrc_prepare() {\n"
            ret += "    cd ${P}\n"
            ret += "    EPATCH_SOURCE=\"${FILESDIR}\""
            ret += " EPATCH_SUFFIX=\"patch\" \\\n"
            ret += "    EPATCH_FORCE=\"yes\" epatch\n"
            if self.build_type in ['catkin', 'cmake']:
                ret += "    ros-cmake_src_prepare\n"
            ret += "}\n"

        # source configuration
        if self.name == 'opencv3':
            ret += "\nsrc_configure() {\n"
            ret += "    filter-flags '-march=*' '-mcpu=*' '-mtune=*'\n"
            ret += "    if [[ $(gcc-major-version) -gt 4 ]]; then\n"
            ret += "        local mycmakeargs=(\n"
            ret += "            -DWITH_CUDA=OFF\n"
            ret += "        )\n"
            ret += '        ewarn "Cuda does not support GCC > 4, so cuda'
            ret += ' has been disabled."\n'
            ret += "    fi\n"
            ret += "    ros-cmake_src_configure\n"
            ret += "}\n"
        elif self.name == 'stage':
            ret += "\nsrc_configure() {\n"
            ret += "    filter-flags '-std=*'\n"
            ret += "    ros-cmake_src_configure\n"
            ret += "}\n"

        if len(self.unresolved_deps) > 0:
            raise UnresolvedDependency("failed to satisfy dependencies!")

        return ret.replace('    ', '\t')