Patchwork [daisy,1/4] tcf-agent: add systemd support

login
register
mail settings
Submitter Otavio Salvador
Date May 14, 2014, 8:30 p.m.
Message ID <1400099434-22527-1-git-send-email-otavio@ossystems.com.br>
Download mbox | patch
Permalink /patch/72161/
State New
Headers show

Comments

Otavio Salvador - May 14, 2014, 8:30 p.m.
From: Chen Qi <Qi.Chen@windriver.com>

Add systemd unit file tcf-agent.service.

(From OE-Core rev: 1a4feebf98780f586bf2e81cf9844e6805a50799)

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/recipes-devtools/tcf-agent/tcf-agent/tcf-agent.service | 10 ++++++++++
 meta/recipes-devtools/tcf-agent/tcf-agent_git.bb            |  8 +++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-devtools/tcf-agent/tcf-agent/tcf-agent.service
Khem Raj - May 14, 2014, 10:04 p.m.
On Wed, May 14, 2014 at 1:30 PM, Otavio Salvador
<otavio@ossystems.com.br> wrote:
> +       install -d ${D}${systemd_unitdir}/system
> +       install -m 0644 ${WORKDIR}/tcf-agent.service ${D}${systemd_unitdir}/system
> +       sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/tcf-agent.service

shouldn't this happened if systemd is enabled in distro
Otavio Salvador - May 15, 2014, 12:24 p.m.
On Wed, May 14, 2014 at 7:04 PM, Khem Raj <raj.khem@gmail.com> wrote:
> On Wed, May 14, 2014 at 1:30 PM, Otavio Salvador
> <otavio@ossystems.com.br> wrote:
>> +       install -d ${D}${systemd_unitdir}/system
>> +       install -m 0644 ${WORKDIR}/tcf-agent.service ${D}${systemd_unitdir}/system
>> +       sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/tcf-agent.service
>
> shouldn't this happened if systemd is enabled in distro

Agreed. Added Chen Qi in Cc.
Qi.Chen@windriver.com - May 16, 2014, 2:05 a.m.
On 05/15/2014 08:24 PM, Otavio Salvador wrote:
> On Wed, May 14, 2014 at 7:04 PM, Khem Raj <raj.khem@gmail.com> wrote:
>> On Wed, May 14, 2014 at 1:30 PM, Otavio Salvador
>> <otavio@ossystems.com.br> wrote:
>>> +       install -d ${D}${systemd_unitdir}/system
>>> +       install -m 0644 ${WORKDIR}/tcf-agent.service ${D}${systemd_unitdir}/system
>>> +       sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/tcf-agent.service
>> shouldn't this happened if systemd is enabled in distro
> Agreed. Added Chen Qi in Cc.
>

In systemd.bbclass, there's function to remove things under 
${systemdunitdir} if 'systemd' is not in DISTRO_FEATURES. So I think 
there's no need to add a check here.

Below are the related codes.

python rm_systemd_unitdir (){
     import shutil
     if not bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d):
         systemd_unitdir = oe.path.join(d.getVar("D", True), 
d.getVar('systemd_unitdir', True))
         if os.path.exists(systemd_unitdir):
             shutil.rmtree(systemd_unitdir)
         systemd_libdir = os.path.dirname(systemd_unitdir)
         if (os.path.exists(systemd_libdir) and not 
os.listdir(systemd_libdir)):
             os.rmdir(systemd_libdir)
}
do_install[postfuncs] += "rm_systemd_unitdir "

Best Regards,
Chen Qi
Khem Raj - May 16, 2014, 4:55 a.m.
On Thu, May 15, 2014 at 7:05 PM, ChenQi <Qi.Chen@windriver.com> wrote:
> On 05/15/2014 08:24 PM, Otavio Salvador wrote:
>>
>> On Wed, May 14, 2014 at 7:04 PM, Khem Raj <raj.khem@gmail.com> wrote:
>>>
>>> On Wed, May 14, 2014 at 1:30 PM, Otavio Salvador
>>> <otavio@ossystems.com.br> wrote:
>>>>
>>>> +       install -d ${D}${systemd_unitdir}/system
>>>> +       install -m 0644 ${WORKDIR}/tcf-agent.service
>>>> ${D}${systemd_unitdir}/system
>>>> +       sed -i -e 's,@SBINDIR@,${sbindir},g'
>>>> ${D}${systemd_unitdir}/system/tcf-agent.service
>>>
>>> shouldn't this happened if systemd is enabled in distro
>>
>> Agreed. Added Chen Qi in Cc.
>>
>
> In systemd.bbclass, there's function to remove things under
> ${systemdunitdir} if 'systemd' is not in DISTRO_FEATURES. So I think there's
> no need to add a check here.
>
> Below are the related codes.
>
> python rm_systemd_unitdir (){
>     import shutil
>     if not bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d):
>         systemd_unitdir = oe.path.join(d.getVar("D", True),
> d.getVar('systemd_unitdir', True))
>         if os.path.exists(systemd_unitdir):
>             shutil.rmtree(systemd_unitdir)
>         systemd_libdir = os.path.dirname(systemd_unitdir)
>         if (os.path.exists(systemd_libdir) and not
> os.listdir(systemd_libdir)):
>             os.rmdir(systemd_libdir)
> }
> do_install[postfuncs] += "rm_systemd_unitdir "

I see. That makes sense.

>
> Best Regards,
> Chen Qi

Patch

diff --git a/meta/recipes-devtools/tcf-agent/tcf-agent/tcf-agent.service b/meta/recipes-devtools/tcf-agent/tcf-agent/tcf-agent.service
new file mode 100644
index 0000000..5d7a586
--- /dev/null
+++ b/meta/recipes-devtools/tcf-agent/tcf-agent/tcf-agent.service
@@ -0,0 +1,10 @@ 
+[Unit]
+Description=Target Communication Framework agent
+After=network.target
+
+[Service]
+Type=forking
+ExecStart=@SBINDIR@/tcf-agent -d -L- -l0
+
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file
diff --git a/meta/recipes-devtools/tcf-agent/tcf-agent_git.bb b/meta/recipes-devtools/tcf-agent/tcf-agent_git.bb
index 1eb0021..616a6a7 100644
--- a/meta/recipes-devtools/tcf-agent/tcf-agent_git.bb
+++ b/meta/recipes-devtools/tcf-agent/tcf-agent_git.bb
@@ -12,6 +12,7 @@  PR = "r2"
 SRC_URI = "git://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git \
            file://fix_ranlib.patch \
            file://tcf-agent.init \
+           file://tcf-agent.service \
           "
 
 DEPENDS = "util-linux openssl"
@@ -19,7 +20,9 @@  RDEPENDS_${PN} = "bash"
 
 S = "${WORKDIR}/git"
 
-inherit update-rc.d
+inherit update-rc.d systemd
+
+SYSTEMD_SERVICE_${PN} = "tcf-agent.service"
 
 INITSCRIPT_NAME = "tcf-agent"
 INITSCRIPT_PARAMS = "start 99 3 5 . stop 20 0 1 2 6 ."
@@ -44,5 +47,8 @@  do_install() {
 	oe_runmake install INSTALLROOT=${D}
 	install -d ${D}${sysconfdir}/init.d/
 	install -m 0755 ${WORKDIR}/tcf-agent.init ${D}${sysconfdir}/init.d/tcf-agent
+	install -d ${D}${systemd_unitdir}/system
+	install -m 0644 ${WORKDIR}/tcf-agent.service ${D}${systemd_unitdir}/system
+	sed -i -e 's,@SBINDIR@,${sbindir},g' ${D}${systemd_unitdir}/system/tcf-agent.service
 }