From 3f77ac93ffb0bc81e04c8514f12d405dfdea9e89 Mon Sep 17 00:00:00 2001 From: Herb Kuta Date: Sat, 18 May 2019 12:31:08 -0700 Subject: [PATCH] DRAFT ros-workspace.inc: Move setup scripts out of ${prefix} ros-workspace installs its setup scripts under , which is an unnatural location when is /usr. Move them to be under /profile.d/ros and create "ros_" prefixed symlinks to them under . If "ros-workspace-implicit" appears in DISTRO_FEATURES, create a ros.sh that sources ros/setup.sh, thereby setting up the ROS workspace for every login shell. --- includes-ros2/ros-workspace/ros-workspace.inc | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 includes-ros2/ros-workspace/ros-workspace.inc diff --git a/includes-ros2/ros-workspace/ros-workspace.inc b/includes-ros2/ros-workspace/ros-workspace.inc new file mode 100644 index 0000000..d7328fb --- /dev/null +++ b/includes-ros2/ros-workspace/ros-workspace.inc @@ -0,0 +1,45 @@ +# Copyright (c) 2019 LG Electronics, Inc. + +# ASSERT( == /usr) +# ros-workspace installs its setup scripts under , which is an unnatural location when is /usr. Move them to be +# under /profile.d/ros and create "ros_" prefixed symlinks to them under . If "ros-implicit-workspace" +# appears in DISTRO_FEATURES, create a ros.sh that sources ros/setup.sh, thereby setting up the ROS workspace for every login +# shell. +do_install_append() { + profile_dir=${sysconfdir}/profile.d/ros + mkdir -p ${D}$profile_dir + cd ${D}$profile_dir + + mv ${D}${prefix}/*setup.bash . + mv ${D}${prefix}/*setup.zsh . + mv ${D}${prefix}/*setup.sh . + mv ${D}${prefix}/_order_packages.py . + + for f in *setup.bash *setup.zsh; do + # Hardcode AMENT_CURRENT_PREFIX and the directory where these files reside. + sed -i -e '/AMENT_CURRENT_PREFIX=/ s@=.*@=${prefix}@' \ + -e '/\$AMENT_CURRENT_PREFIX/ s@\$AMENT_CURRENT_PREFIX@'$profile_dir'@' $f + done + + # Add special case handling for AMENT_CURRENT_PREFIX == /usr + sed -i -e '/for _path.*_UNIQUE_PREFIX_PATH.*do/ s@do.*@do [ $_path = ${prefix} ] \&\& _path='$profile_dir'@' \ + -e '/AMENT_CURRENT_PREFIX=.*_path/ s@_path.*@_path; [ $_path = '$profile_dir' ] \&\& AMENT_CURRENT_PREFIX=${prefix}@' \ + setup.sh + + # Don't attempt to use the build-time Python executable on the target and hardcode the directory where _order_packages.py + # resides. + sed -i -e '/^_ament_python_executable=/ s@=.*@=${bindir}/${PYTHON_PN}@' \ + -e '/_order_packages\.py/ s@\$AMENT_CURRENT_PREFIX/@'$profile_dir'/@' \ + local_setup.sh + + mkdir -p ${D}${bindir} + for f in *setup.bash *setup.zsh *setup.sh; do + ln -s $profile_dir/$f ${D}${bindir}/ros_$f + done + + if ${@bb.utils.contains('DISTRO_FEATURES', 'ros-implicit-workspace', 'true', 'false', d)}; then + echo ". $profile_dir/setup.sh" > ../ros.sh + fi + + cd - > /dev/null +}