Patchwork systemd: Remove init.d dir if systemd unit file is present and sysvinit not a distro feature

login
register
mail settings
Submitter Shakeel, Muhammad
Date July 23, 2013, 10:03 a.m.
Message ID <1374573823-27458-1-git-send-email-muhammad_shakeel@mentor.com>
Download mbox | patch
Permalink /patch/54209/
State New
Headers show

Comments

Shakeel, Muhammad - July 23, 2013, 10:03 a.m.
From: Muhammad Shakeel <muhammad_shakeel@mentor.com>

If systemd is supported DISTRO_FEATURE and sysvinit is not and also if
systemd_unitdir contains a service file(s) then no need to keep init.d scripts
for sysvinit compatibility.

Signed-off-by: Muhammad Shakeel <muhammad_shakeel@mentor.com>
---
 meta/classes/systemd.bbclass |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
Enrico Scholz - July 23, 2013, 10:46 a.m.
"Shakeel, Muhammad"
<muhammad_shakeel-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org> writes:

> If systemd is supported DISTRO_FEATURE and sysvinit is not and also if
> systemd_unitdir contains a service file(s) then no need to keep init.d scripts
> for sysvinit compatibility.
> ...
> +            for filename in os.listdir(systemd_unitdir):
> +                if filename.endswith(".service"):

why only .service?  Other systemd files (.socket, .mount, .path, ...)
can also replace initscripts.


Enrico
Shakeel, Muhammad - July 24, 2013, 1:22 p.m.
On 07/23/2013 03:46 PM, Enrico Scholz wrote:
> "Shakeel, Muhammad"
> <muhammad_shakeel-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org> writes:
>
>> If systemd is supported DISTRO_FEATURE and sysvinit is not and also if
>> systemd_unitdir contains a service file(s) then no need to keep init.d scripts
>> for sysvinit compatibility.
>> ...
>> +            for filename in os.listdir(systemd_unitdir):
>> +                if filename.endswith(".service"):
> why only .service?  Other systemd files (.socket, .mount, .path, ...)
> can also replace initscripts.
>
Other systemd unit files are normally accompanied with a .service file 
(this is just I observed and not mandatory).

If we come across any package which is not providing .service file but 
only some other type of systemd unit file for initscripts replacement 
then we can always add check for that type.
According to systemd documentation there can be 10 types of systemd unit 
files and checking for all here can be a little overhead.

Thanks
Paul Eggleton - July 24, 2013, 1:55 p.m.
On Wednesday 24 July 2013 18:22:11 Muhammad Shakeel wrote:
> On 07/23/2013 03:46 PM, Enrico Scholz wrote:
> > "Shakeel, Muhammad"
> > 
> > <muhammad_shakeel-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org> writes:
> >> If systemd is supported DISTRO_FEATURE and sysvinit is not and also if
> >> systemd_unitdir contains a service file(s) then no need to keep init.d
> >> scripts for sysvinit compatibility.
> >> ...
> >> +            for filename in os.listdir(systemd_unitdir):
> > 
> >> +                if filename.endswith(".service"):
> > why only .service?  Other systemd files (.socket, .mount, .path, ...)
> > can also replace initscripts.
> 
> Other systemd unit files are normally accompanied with a .service file
> (this is just I observed and not mandatory).
> 
> If we come across any package which is not providing .service file but
> only some other type of systemd unit file for initscripts replacement
> then we can always add check for that type.
> According to systemd documentation there can be 10 types of systemd unit
> files and checking for all here can be a little overhead.

Would it work to simply check for any files instaled into systemd_unitdir?

Cheers,
Paul
Ross Burton - July 25, 2013, 9:56 a.m.
On 24 July 2013 14:55, Paul Eggleton <paul.eggleton@linux.intel.com> wrote:
> Would it work to simply check for any files instaled into systemd_unitdir?

Agreed - the list of file types has grown over time so we'd been
constantly chasing systemd, and it's not like anything else is dropped
into this directory.

Ross
Shakeel, Muhammad - July 25, 2013, 10:10 a.m.
On 07/25/2013 02:56 PM, Burton, Ross wrote:
> On 24 July 2013 14:55, Paul Eggleton <paul.eggleton@linux.intel.com> wrote:
>> Would it work to simply check for any files instaled into systemd_unitdir?
> Agreed - the list of file types has grown over time so we'd been
> constantly chasing systemd, and it's not like anything else is dropped
> into this directory.
>
> Ross
Ok, I will send a V2 with updated check.

Thanks
Qi.Chen@windriver.com - July 25, 2013, 11:08 a.m.
On 07/23/2013 06:03 PM, Shakeel, Muhammad wrote:
> From: Muhammad Shakeel <muhammad_shakeel@mentor.com>
>
> If systemd is supported DISTRO_FEATURE and sysvinit is not and also if
> systemd_unitdir contains a service file(s) then no need to keep init.d scripts
> for sysvinit compatibility.
>
> Signed-off-by: Muhammad Shakeel <muhammad_shakeel@mentor.com>
> ---
>   meta/classes/systemd.bbclass |   19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
>
> diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
> index 9763faa..55f378e 100644
> --- a/meta/classes/systemd.bbclass
> +++ b/meta/classes/systemd.bbclass
> @@ -170,3 +170,22 @@ python rm_systemd_unitdir (){
>               shutil.rmtree(systemd_unitdir)
>   }
>   do_install[postfuncs] += "rm_systemd_unitdir "
> +
> +python rm_sysvinit_initddir (){
> +    import shutil
> +    if ("systemd" in d.getVar("DISTRO_FEATURES", True).split() and
> +        "sysvinit" not in d.getVar("DISTRO_FEATURES", True).split()):
> +        service_file_exists = False
> +        systemd_unitdir = oe.path.join(d.getVar("D", True), d.getVar('systemd_unitdir', True), "system")
> +        if os.path.exists(systemd_unitdir):
> +            for filename in os.listdir(systemd_unitdir):
> +                if filename.endswith(".service"):
> +                    service_file_exists = True
> +                    break
> +
> +        if service_file_exists:
> +            sysv_initddir = oe.path.join(d.getVar("D", True), d.getVar('INIT_D_DIR', True))
> +            if os.path.exists(sysv_initddir):
> +                shutil.rmtree(sysv_initddir)
> +}
> +do_install[postfuncs] += "rm_sysvinit_initddir "
Hi,

I just tried this patch out.
It resulted in the following warning.

WARNING: busybox: NOT adding alternative provide /etc/init.d/syslog: 
/etc/init.d/syslog.busybox does not exist

I know this warning is harmless. But it's still somewhat misleading. So 
are we going to do something about it?

//Chen Qi

//Chen Qi
Shakeel, Muhammad - July 25, 2013, 11:19 a.m.
On 07/25/2013 04:08 PM, ChenQi wrote:
> I just tried this patch out.
> It resulted in the following warning.
>
> WARNING: busybox: NOT adding alternative provide /etc/init.d/syslog: 
> /etc/init.d/syslog.busybox does not exist
>
> I know this warning is harmless. But it's still somewhat misleading. 
> So are we going to do something about it?
>
Yes, I am going to send a V2 and that will handle this warning.

Thanks

Patch

diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
index 9763faa..55f378e 100644
--- a/meta/classes/systemd.bbclass
+++ b/meta/classes/systemd.bbclass
@@ -170,3 +170,22 @@  python rm_systemd_unitdir (){
             shutil.rmtree(systemd_unitdir)
 }
 do_install[postfuncs] += "rm_systemd_unitdir "
+
+python rm_sysvinit_initddir (){
+    import shutil
+    if ("systemd" in d.getVar("DISTRO_FEATURES", True).split() and
+        "sysvinit" not in d.getVar("DISTRO_FEATURES", True).split()):
+        service_file_exists = False
+        systemd_unitdir = oe.path.join(d.getVar("D", True), d.getVar('systemd_unitdir', True), "system")
+        if os.path.exists(systemd_unitdir):
+            for filename in os.listdir(systemd_unitdir):
+                if filename.endswith(".service"):
+                    service_file_exists = True
+                    break
+
+        if service_file_exists:
+            sysv_initddir = oe.path.join(d.getVar("D", True), d.getVar('INIT_D_DIR', True))
+            if os.path.exists(sysv_initddir):
+                shutil.rmtree(sysv_initddir)
+}
+do_install[postfuncs] += "rm_sysvinit_initddir "