diff --git a/bloom/generators/rosrpm.py b/bloom/generators/rosrpm.py index ad8ae70f..29540b18 100644 --- a/bloom/generators/rosrpm.py +++ b/bloom/generators/rosrpm.py @@ -44,6 +44,8 @@ from bloom.logging import info +from bloom.rosdistro_api import get_index + from bloom.util import get_distro_list_prompt @@ -86,6 +88,37 @@ def fallback_resolver(key, peer_packages, rosdistro=self.rosdistro): fallback_resolver=fallback_resolver ) subs['Package'] = rosify_package_name(subs['Package'], self.rosdistro) + + # ROS 2 specific bloom extensions. + ros2_distros = [ + name for name, values in get_index().distributions.items() + if values.get('distribution_type') == 'ros2'] + if self.rosdistro in ros2_distros: + # Add ros-workspace package as a dependency to any package other + # than ros_workspace and its dependencies. + if package.name not in ['ament_cmake_core', 'ament_package', 'ros_workspace']: + workspace_pkg_name = rosify_package_name('ros-workspace', self.rosdistro) + subs['BuildDepends'].append(workspace_pkg_name) + subs['Depends'].append(workspace_pkg_name) + + # Add packages necessary to build vendor typesupport for rosidl_interface_packages to their + # build dependencies. + if self.rosdistro in ros2_distros and \ + self.rosdistro not in ('r2b2', 'r2b3', 'ardent') and \ + 'rosidl_interface_packages' in [p.name for p in package.member_of_groups]: + ROS2_VENDOR_TYPESUPPORT_DEPENDENCIES = [ + 'rmw-connext-cpp', + 'rmw-fastrtps-cpp', + 'rmw-implementation', + 'rmw-opensplice-cpp', + 'rosidl-typesupport-connext-c', + 'rosidl-typesupport-connext-cpp', + 'rosidl-typesupport-opensplice-c', + 'rosidl-typesupport-opensplice-cpp', + ] + + subs['BuildDepends'] += [ + rosify_package_name(name, self.rosdistro) for name in ROS2_VENDOR_TYPESUPPORT_DEPENDENCIES] return subs def generate_branching_arguments(self, package, branch): diff --git a/bloom/generators/rpm/generator.py b/bloom/generators/rpm/generator.py index d1e43ba0..0ce0188b 100644 --- a/bloom/generators/rpm/generator.py +++ b/bloom/generators/rpm/generator.py @@ -267,25 +267,9 @@ def generate_substitutions_from_package( elif build_type == 'cmake': pass elif build_type == 'ament_cmake': - error( - "Build type '{}' is not supported by this version of bloom.". - format(build_type), exit=True) + pass elif build_type == 'ament_python': - error( - "Build type '{}' is not supported by this version of bloom.". - format(build_type), exit=True) - # Don't set the install-scripts flag if it's already set in setup.cfg. - package_path = os.path.abspath(os.path.dirname(package.filename)) - setup_cfg_path = os.path.join(package_path, 'setup.cfg') - data['pass_install_scripts'] = True - if os.path.isfile(setup_cfg_path): - setup_cfg = SafeConfigParser() - setup_cfg.read([setup_cfg_path]) - if ( - setup_cfg.has_option('install', 'install-scripts') or - setup_cfg.has_option('install', 'install_scripts') - ): - data['pass_install_scripts'] = False + pass else: error( "Build type '{}' is not supported by this version of bloom.". diff --git a/bloom/generators/rpm/templates/ament_cmake/template.spec.em b/bloom/generators/rpm/templates/ament_cmake/template.spec.em new file mode 100644 index 00000000..6bebfdfc --- /dev/null +++ b/bloom/generators/rpm/templates/ament_cmake/template.spec.em @@ -0,0 +1,50 @@ +%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') +%global __provides_exclude_from ^@(InstallationPrefix)/.*$ +%global __requires_exclude_from ^@(InstallationPrefix)/.*$ + +Name: @(Package) +Version: @(Version) +Release: @(RPMInc)%{?dist} +Summary: ROS @(Name) package + +License: @(License) +@[if Homepage and Homepage != '']URL: @(Homepage)@\n@[end if]Source0: %{name}-%{version}.tar.gz +@[if NoArch]@\nBuildArch: noarch@\n@[end if] +@[for p in Depends]Requires: @p@\n@[end for]@[for p in BuildDepends]BuildRequires: @p@\n@[end for]@[for p in Conflicts]Conflicts: @p@\n@[end for]@[for p in Replaces]Obsoletes: @p@\n@[end for] +%description +@(Description) + +%prep +%autosetup + +%build +# In case we're installing to a non-standard location, look for a setup.sh +# in the install tree that was dropped by catkin, and source it. It will +# set things like CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH. +if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi +mkdir -p obj-%{_target_platform} && cd obj-%{_target_platform} +%cmake3 \ + -UINCLUDE_INSTALL_DIR \ + -ULIB_INSTALL_DIR \ + -USYSCONF_INSTALL_DIR \ + -USHARE_INSTALL_PREFIX \ + -ULIB_SUFFIX \ + -DCMAKE_INSTALL_LIBDIR="lib" \ + -DCMAKE_INSTALL_PREFIX="@(InstallationPrefix)" \ + -DCMAKE_PREFIX_PATH="@(InstallationPrefix)" \ + -DSETUPTOOLS_DEB_LAYOUT=OFF \ + .. + +%make_build + +%install +# In case we're installing to a non-standard location, look for a setup.sh +# in the install tree that was dropped by catkin, and source it. It will +# set things like CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH. +if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi +%make_install -C obj-%{_target_platform} + +%files +@(InstallationPrefix) + +%changelog@[for change_version, (change_date, main_name, main_email) in changelogs]@\n* @(change_date) @(main_name) <@(main_email)> - @(change_version)@\n- Autogenerated by Bloom@\n@[end for] diff --git a/bloom/generators/rpm/templates/ament_python/template.spec.em b/bloom/generators/rpm/templates/ament_python/template.spec.em new file mode 100644 index 00000000..08855df0 --- /dev/null +++ b/bloom/generators/rpm/templates/ament_python/template.spec.em @@ -0,0 +1,37 @@ +%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') +%global __provides_exclude_from ^@(InstallationPrefix)/.*$ +%global __requires_exclude_from ^@(InstallationPrefix)/.*$ + +Name: @(Package) +Version: @(Version) +Release: @(RPMInc)%{?dist} +Summary: ROS @(Name) package + +License: @(License) +@[if Homepage and Homepage != '']URL: @(Homepage)@\n@[end if]Source0: %{name}-%{version}.tar.gz +@[if NoArch]@\nBuildArch: noarch@\n@[end if] +@[for p in Depends]Requires: @p@\n@[end for]@[for p in sorted(BuildDepends + ['python%{python3_pkgversion}-devel'])]BuildRequires: @p@\n@[end for]@[for p in Conflicts]Conflicts: @p@\n@[end for]@[for p in Replaces]Obsoletes: @p@\n@[end for] +%description +@(Description) + +%prep +%autosetup + +%build +# In case we're installing to a non-standard location, look for a setup.sh +# in the install tree that was dropped by catkin, and source it. It will +# set things like CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH. +if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi +%py3_build + +%install +# In case we're installing to a non-standard location, look for a setup.sh +# in the install tree that was dropped by catkin, and source it. It will +# set things like CMAKE_PREFIX_PATH, PKG_CONFIG_PATH, and PYTHONPATH. +if [ -f "@(InstallationPrefix)/setup.sh" ]; then . "@(InstallationPrefix)/setup.sh"; fi +%py3_install -- --prefix "@(InstallationPrefix)" + +%files +@(InstallationPrefix) + +%changelog@[for change_version, (change_date, main_name, main_email) in changelogs]@\n* @(change_date) @(main_name) <@(main_email)> - @(change_version)@\n- Autogenerated by Bloom@\n@[end for]