Skip to content

Commit

Permalink
Add Ament package support to RPM generation (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
cottsay authored and nuclearsandwich committed Oct 18, 2019
1 parent 97330d9 commit 7e67936
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 18 deletions.
33 changes: 33 additions & 0 deletions bloom/generators/rosrpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@

from bloom.logging import info

from bloom.rosdistro_api import get_index

from bloom.util import get_distro_list_prompt


Expand Down Expand Up @@ -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):
Expand Down
20 changes: 2 additions & 18 deletions bloom/generators/rpm/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.".
Expand Down
50 changes: 50 additions & 0 deletions bloom/generators/rpm/templates/ament_cmake/template.spec.em
Original file line number Diff line number Diff line change
@@ -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]
37 changes: 37 additions & 0 deletions bloom/generators/rpm/templates/ament_python/template.spec.em
Original file line number Diff line number Diff line change
@@ -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]

0 comments on commit 7e67936

Please sign in to comment.