[oe] [PATCH][meta-networking] systemd.bbclass: delete dangling symblink

Martin Jansa martin.jansa at gmail.com
Wed Jul 8 10:43:28 UTC 2015


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 at 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 at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.openembedded.org/pipermail/openembedded-devel/attachments/20150708/d5240bb5/attachment-0002.sig>


More information about the Openembedded-devel mailing list