From 69807fe6aaad4936430e5d01e9dad2ca49071882 Mon Sep 17 00:00:00 2001
From: Esteve Fernandez <esteve@osrfoundation.org>
Date: Mon, 17 Feb 2014 19:52:00 +0100
Subject: [PATCH] roslaunch: add systemd unit files (resolves #224)

---
 .../ros-comm/roslaunch/roscore-default        |  4 +++
 .../ros-comm/roslaunch/roscore.service        | 12 ++++++++
 recipes-ros/ros-comm/roslaunch_1.10.2.bb      | 28 ++++++++++++++++++-
 3 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 recipes-ros/ros-comm/roslaunch/roscore-default
 create mode 100644 recipes-ros/ros-comm/roslaunch/roscore.service

diff --git a/recipes-ros/ros-comm/roslaunch/roscore-default b/recipes-ros/ros-comm/roslaunch/roscore-default
new file mode 100644
index 0000000..71df34e
--- /dev/null
+++ b/recipes-ros/ros-comm/roslaunch/roscore-default
@@ -0,0 +1,4 @@
+ROS_ROOT=/usr
+ROS_PORT=11311
+ROS_MASTER_URI=http://localhost:$ROS_PORT
+CMAKE_PREFIX_PATH=$ROS_ROOT
diff --git a/recipes-ros/ros-comm/roslaunch/roscore.service b/recipes-ros/ros-comm/roslaunch/roscore.service
new file mode 100644
index 0000000..49496e5
--- /dev/null
+++ b/recipes-ros/ros-comm/roslaunch/roscore.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Launcher for the ROS master, parameter server and rosout logging node
+After=network.target ros-set-cmake-prefix
+
+[Service]
+EnvironmentFile=/etc/default/roscore
+ExecStartPre=/bin/touch ${CMAKE_PREFIX_PATH}/.catkin
+ExecStart=/usr/bin/roscore -p $ROS_PORT
+Restart=on-abort
+
+[Install]
+WantedBy=multi-user.target
diff --git a/recipes-ros/ros-comm/roslaunch_1.10.2.bb b/recipes-ros/ros-comm/roslaunch_1.10.2.bb
index 6776f9f..38e6de2 100644
--- a/recipes-ros/ros-comm/roslaunch_1.10.2.bb
+++ b/recipes-ros/ros-comm/roslaunch_1.10.2.bb
@@ -4,9 +4,14 @@ SECTION = "devel"
 LICENSE = "BSD"
 LIC_FILES_CHKSUM = "file://package.xml;beginline=16;endline=16;md5=d566ef916e9dedc494f5f793a6690ba5"
 
+PR = "r1"
+
 require ros-comm.inc
 
-SRC_URI += "file://0001-increase-rosmaster-timeout.patch"
+SRC_URI += "file://0001-increase-rosmaster-timeout.patch \
+  file://roscore.service \
+  file://roscore-default \
+"
 
 ROS_PKG_SUBDIR = "tools"
 
@@ -27,3 +32,24 @@ RDEPENDS_${PN} = "\
   rosout \
   rosparam \
 "
+
+do_install_append() {
+  install -d ${D}/${sysconfdir}/default
+  install -m 0644 ${WORKDIR}/roscore-default ${D}/${sysconfdir}/default/roscore
+
+  # Install systemd unit file
+  install -d ${D}${systemd_unitdir}/system/
+  install -m 0644 ${WORKDIR}/roscore.service ${D}${systemd_unitdir}/system/roscore.service
+}
+
+FILES_${PN}-systemd += "${sysconfdir}/default/roscore \
+"
+
+CONFFILES_${PN}-systemd += "${sysconfdir}/default/roscore \
+"
+
+inherit systemd
+PACKAGES += "${PN}-systemd"
+SYSTEMD_PACKAGES = "${PN}-systemd"
+SYSTEMD_SERVICE = "roscore.service \
+"
-- 
GitLab