All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][meta-networking] systemd.bbclass: delete dangling symblink
@ 2015-07-08  3:23 Jian Liu
  2015-07-08 10:43 ` Martin Jansa
  0 siblings, 1 reply; 2+ messages in thread
From: Jian Liu @ 2015-07-08  3:23 UTC (permalink / raw)
  To: openembedded-devel

If only systemd is enabled, scripts of sysvinit under "/etc/init.d/"
will be deleted. But there may be some symblinks /etc/rc*/ that
points to the files under "/etc/init.d/". We need to delete them.

Signed-off-by: Jian Liu <jian.liu@windriver.com>
---
 meta/classes/systemd.bbclass | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
index c34884b..ff3e0f8 100644
--- a/meta/classes/systemd.bbclass
+++ b/meta/classes/systemd.bbclass
@@ -184,6 +184,31 @@ do_install[postfuncs] += "rm_systemd_unitdir "
 python rm_sysvinit_initddir (){
     import shutil
     sysv_initddir = oe.path.join(d.getVar("D", True), (d.getVar('INIT_D_DIR', True) or "/etc/init.d"))
+    sysv_rcdirs = []
+    cpath = oe.cachedpath.CachedPath()
+
+    def check_dangling_sym(file,inst_root):
+        if not cpath.islink(file):
+            return False
+
+        rtarget = cpath.realpath(file, inst_root, True, assume_dir = True)
+        if not cpath.lexists(rtarget):
+            return True
+
+        return False
+
+    # delete dangling symblink under rc*
+    def rm_sysv_rcdirs():
+        dest = d.getVar("D", True)
+        rcdirs = "rc.d rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d rcS.d"
+
+        for rcdir in rcdirs.split():
+            path = dest + "/etc/" + rcdir
+            for walk_root, walk_dirs, walk_files in cpath.walk(path):
+                for file in walk_files:
+                    file = walk_root + "/" + file
+                    if check_dangling_sym(file, walk_root):
+                        sysv_rcdirs.append(file)
 
     if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and \
         not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d) and \
@@ -193,5 +218,9 @@ python rm_sysvinit_initddir (){
         # If systemd_unitdir contains anything, delete sysv_initddir
         if (os.path.exists(systemd_unitdir) and os.listdir(systemd_unitdir)):
             shutil.rmtree(sysv_initddir)
+
+            rm_sysv_rcdirs()
+            for rcdir in sysv_rcdirs:
+                os.remove(rcdir)
 }
 do_install[postfuncs] += "rm_sysvinit_initddir "
-- 
1.8.5.2.233.g932f7e4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][meta-networking] systemd.bbclass: delete dangling symblink
  2015-07-08  3:23 [PATCH][meta-networking] systemd.bbclass: delete dangling symblink Jian Liu
@ 2015-07-08 10:43 ` Martin Jansa
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Jansa @ 2015-07-08 10:43 UTC (permalink / raw)
  To: openembedded-devel

[-- Attachment #1: Type: text/plain, Size: 2729 bytes --]

On Wed, Jul 08, 2015 at 11:23:15AM +0800, Jian Liu wrote:
> If only systemd is enabled, scripts of sysvinit under "/etc/init.d/"
> will be deleted. But there may be some symblinks /etc/rc*/ that
> points to the files under "/etc/init.d/". We need to delete them.

Wrong ML

> Signed-off-by: Jian Liu <jian.liu@windriver.com>
> ---
>  meta/classes/systemd.bbclass | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/meta/classes/systemd.bbclass b/meta/classes/systemd.bbclass
> index c34884b..ff3e0f8 100644
> --- a/meta/classes/systemd.bbclass
> +++ b/meta/classes/systemd.bbclass
> @@ -184,6 +184,31 @@ do_install[postfuncs] += "rm_systemd_unitdir "
>  python rm_sysvinit_initddir (){
>      import shutil
>      sysv_initddir = oe.path.join(d.getVar("D", True), (d.getVar('INIT_D_DIR', True) or "/etc/init.d"))
> +    sysv_rcdirs = []
> +    cpath = oe.cachedpath.CachedPath()
> +
> +    def check_dangling_sym(file,inst_root):
> +        if not cpath.islink(file):
> +            return False
> +
> +        rtarget = cpath.realpath(file, inst_root, True, assume_dir = True)
> +        if not cpath.lexists(rtarget):
> +            return True
> +
> +        return False
> +
> +    # delete dangling symblink under rc*
> +    def rm_sysv_rcdirs():
> +        dest = d.getVar("D", True)
> +        rcdirs = "rc.d rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d rcS.d"
> +
> +        for rcdir in rcdirs.split():
> +            path = dest + "/etc/" + rcdir
> +            for walk_root, walk_dirs, walk_files in cpath.walk(path):
> +                for file in walk_files:
> +                    file = walk_root + "/" + file
> +                    if check_dangling_sym(file, walk_root):
> +                        sysv_rcdirs.append(file)
>  
>      if bb.utils.contains('DISTRO_FEATURES', 'systemd', True, False, d) and \
>          not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d) and \
> @@ -193,5 +218,9 @@ python rm_sysvinit_initddir (){
>          # If systemd_unitdir contains anything, delete sysv_initddir
>          if (os.path.exists(systemd_unitdir) and os.listdir(systemd_unitdir)):
>              shutil.rmtree(sysv_initddir)
> +
> +            rm_sysv_rcdirs()
> +            for rcdir in sysv_rcdirs:
> +                os.remove(rcdir)
>  }
>  do_install[postfuncs] += "rm_sysvinit_initddir "
> -- 
> 1.8.5.2.233.g932f7e4
> 
> -- 
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 188 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-08 10:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-08  3:23 [PATCH][meta-networking] systemd.bbclass: delete dangling symblink Jian Liu
2015-07-08 10:43 ` Martin Jansa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.