Patchwork [3/3] binconfig.bbclass: fix multilib file conflicts

login
register
mail settings
Submitter Ming Liu
Date April 7, 2014, 11:27 a.m.
Message ID <1396870039-26834-3-git-send-email-ming.liu@windriver.com>
Download mbox | patch
Permalink /patch/70209/
State New
Headers show

Comments

Ming Liu - April 7, 2014, 11:27 a.m.
In most cases binconfig files conflict among multilib packages, to avoid
that, use update-alternatives link *-config from real path with a
PACKAGE_ARCH suffix.

Signed-off-by: Ming Liu <ming.liu@windriver.com>
---
 meta/classes/binconfig.bbclass | 65 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 56 insertions(+), 9 deletions(-)
Richard Purdie - April 7, 2014, 11:36 a.m.
On Mon, 2014-04-07 at 19:27 +0800, Ming Liu wrote:
> In most cases binconfig files conflict among multilib packages, to avoid
> that, use update-alternatives link *-config from real path with a
> PACKAGE_ARCH suffix.
> 
> Signed-off-by: Ming Liu <ming.liu@windriver.com>
> ---
>  meta/classes/binconfig.bbclass | 65 ++++++++++++++++++++++++++++++++++++------
>  1 file changed, 56 insertions(+), 9 deletions(-)

This isn't going in, its complex and supports a minority use case.
binconfig should be dying out, not being extended and shored up like
this.

I'd also add this patch is buggy, its pure luck that update-alternatives
is available at rootfs generation time since its not in a visible
dependency.

So going forward I'd like to see patches which simply delete binconfig
scripts. Where there isn't a .pc alternative we should be adding them
and pushing them upstream.

Cheers,

Richard
Ming Liu - April 8, 2014, 2:27 a.m.
On 04/07/2014 07:36 PM, Richard Purdie wrote:
> On Mon, 2014-04-07 at 19:27 +0800, Ming Liu wrote:
>> In most cases binconfig files conflict among multilib packages, to avoid
>> that, use update-alternatives link *-config from real path with a
>> PACKAGE_ARCH suffix.
>>
>> Signed-off-by: Ming Liu <ming.liu@windriver.com>
>> ---
>>   meta/classes/binconfig.bbclass | 65 ++++++++++++++++++++++++++++++++++++------
>>   1 file changed, 56 insertions(+), 9 deletions(-)
> This isn't going in, its complex and supports a minority use case.
> binconfig should be dying out, not being extended and shored up like
> this.
>
> I'd also add this patch is buggy, its pure luck that update-alternatives
> is available at rootfs generation time since its not in a visible
> dependency.
>
> So going forward I'd like to see patches which simply delete binconfig
> scripts. Where there isn't a .pc alternative we should be adding them
> and pushing them upstream.
Did you mean we'd better remove all *-config scripts, insteaded by 
providing .pc files, and send the changes to all upstreams providing and 
using *-config? That seems a huge work and we need co-operate with a lot 
of projects.

//Ming Liu
>
> Cheers,
>
> Richard
>
>
>
>
>
Richard Purdie - April 8, 2014, 10:03 a.m.
On Tue, 2014-04-08 at 10:27 +0800, Ming Liu wrote:
> On 04/07/2014 07:36 PM, Richard Purdie wrote:
> > On Mon, 2014-04-07 at 19:27 +0800, Ming Liu wrote:
> >> In most cases binconfig files conflict among multilib packages, to avoid
> >> that, use update-alternatives link *-config from real path with a
> >> PACKAGE_ARCH suffix.
> >>
> >> Signed-off-by: Ming Liu <ming.liu@windriver.com>
> >> ---
> >>   meta/classes/binconfig.bbclass | 65 ++++++++++++++++++++++++++++++++++++------
> >>   1 file changed, 56 insertions(+), 9 deletions(-)
> > This isn't going in, its complex and supports a minority use case.
> > binconfig should be dying out, not being extended and shored up like
> > this.
> >
> > I'd also add this patch is buggy, its pure luck that update-alternatives
> > is available at rootfs generation time since its not in a visible
> > dependency.
> >
> > So going forward I'd like to see patches which simply delete binconfig
> > scripts. Where there isn't a .pc alternative we should be adding them
> > and pushing them upstream.
> Did you mean we'd better remove all *-config scripts, insteaded by 
> providing .pc files, and send the changes to all upstreams providing and 
> using *-config? That seems a huge work and we need co-operate with a lot 
> of projects.

Basically, yes, that is what I mean. I might be wrong but I don't think
there are that many projects which don't ship .pc files now and just
have a binconfig as a backup.

Cheers,

Richard
Ming Liu - April 9, 2014, 6:41 a.m.
On 04/08/2014 06:03 PM, Richard Purdie wrote:
> On Tue, 2014-04-08 at 10:27 +0800, Ming Liu wrote:
>> On 04/07/2014 07:36 PM, Richard Purdie wrote:
>>> On Mon, 2014-04-07 at 19:27 +0800, Ming Liu wrote:
>>>> In most cases binconfig files conflict among multilib packages, to avoid
>>>> that, use update-alternatives link *-config from real path with a
>>>> PACKAGE_ARCH suffix.
>>>>
>>>> Signed-off-by: Ming Liu <ming.liu@windriver.com>
>>>> ---
>>>>    meta/classes/binconfig.bbclass | 65 ++++++++++++++++++++++++++++++++++++------
>>>>    1 file changed, 56 insertions(+), 9 deletions(-)
>>> This isn't going in, its complex and supports a minority use case.
>>> binconfig should be dying out, not being extended and shored up like
>>> this.
>>>
>>> I'd also add this patch is buggy, its pure luck that update-alternatives
>>> is available at rootfs generation time since its not in a visible
>>> dependency.
>>>
>>> So going forward I'd like to see patches which simply delete binconfig
>>> scripts. Where there isn't a .pc alternative we should be adding them
>>> and pushing them upstream.
>> Did you mean we'd better remove all *-config scripts, insteaded by
>> providing .pc files, and send the changes to all upstreams providing and
>> using *-config? That seems a huge work and we need co-operate with a lot
>> of projects.
> Basically, yes, that is what I mean. I might be wrong but I don't think
> there are that many projects which don't ship .pc files now and just
> have a binconfig as a backup.
Yes, I also noticed that many of them are providing .pc files as well as 
binconfig as a backup, so I think there must be reasons binconfig 
remained in their projects, that might be for compliable considering,  
so I am not sure they would like to remove them from their projects, but 
I can try to ping them. Nevertheless, the conflicts still exist, we just 
leave them here so far?

//Ming Liu
>
> Cheers,
>
> Richard
>
>
>
>
Richard Purdie - April 9, 2014, 9:42 a.m.
On Wed, 2014-04-09 at 14:41 +0800, Ming Liu wrote:
> On 04/08/2014 06:03 PM, Richard Purdie wrote:
> > On Tue, 2014-04-08 at 10:27 +0800, Ming Liu wrote:
> >> On 04/07/2014 07:36 PM, Richard Purdie wrote:
> >>> On Mon, 2014-04-07 at 19:27 +0800, Ming Liu wrote:
> >>>> In most cases binconfig files conflict among multilib packages, to avoid
> >>>> that, use update-alternatives link *-config from real path with a
> >>>> PACKAGE_ARCH suffix.
> >>>>
> >>>> Signed-off-by: Ming Liu <ming.liu@windriver.com>
> >>>> ---
> >>>>    meta/classes/binconfig.bbclass | 65 ++++++++++++++++++++++++++++++++++++------
> >>>>    1 file changed, 56 insertions(+), 9 deletions(-)
> >>> This isn't going in, its complex and supports a minority use case.
> >>> binconfig should be dying out, not being extended and shored up like
> >>> this.
> >>>
> >>> I'd also add this patch is buggy, its pure luck that update-alternatives
> >>> is available at rootfs generation time since its not in a visible
> >>> dependency.
> >>>
> >>> So going forward I'd like to see patches which simply delete binconfig
> >>> scripts. Where there isn't a .pc alternative we should be adding them
> >>> and pushing them upstream.
> >> Did you mean we'd better remove all *-config scripts, insteaded by
> >> providing .pc files, and send the changes to all upstreams providing and
> >> using *-config? That seems a huge work and we need co-operate with a lot
> >> of projects.
> > Basically, yes, that is what I mean. I might be wrong but I don't think
> > there are that many projects which don't ship .pc files now and just
> > have a binconfig as a backup.
> Yes, I also noticed that many of them are providing .pc files as well as 
> binconfig as a backup, so I think there must be reasons binconfig 
> remained in their projects, that might be for compliable considering,  
> so I am not sure they would like to remove them from their projects, but 
> I can try to ping them. Nevertheless, the conflicts still exist, we just 
> leave them here so far?

I'm thinking we should start deleting the -config files at do_install
time where we know a good .pc file exists and remove the binconfig
inherit. If this causes any problem in software using the package, we
should fix those to use pkgconfig.

Over time the conflicts will stop existing since the binconfig class
will not be used anywhere.

Cheers,

Richard
Ming Liu - April 9, 2014, 10:01 a.m.
On 04/09/2014 05:42 PM, Richard Purdie wrote:
> On Wed, 2014-04-09 at 14:41 +0800, Ming Liu wrote:
>> On 04/08/2014 06:03 PM, Richard Purdie wrote:
>>> On Tue, 2014-04-08 at 10:27 +0800, Ming Liu wrote:
>>>> On 04/07/2014 07:36 PM, Richard Purdie wrote:
>>>>> On Mon, 2014-04-07 at 19:27 +0800, Ming Liu wrote:
>>>>>> In most cases binconfig files conflict among multilib packages, to avoid
>>>>>> that, use update-alternatives link *-config from real path with a
>>>>>> PACKAGE_ARCH suffix.
>>>>>>
>>>>>> Signed-off-by: Ming Liu <ming.liu@windriver.com>
>>>>>> ---
>>>>>>     meta/classes/binconfig.bbclass | 65 ++++++++++++++++++++++++++++++++++++------
>>>>>>     1 file changed, 56 insertions(+), 9 deletions(-)
>>>>> This isn't going in, its complex and supports a minority use case.
>>>>> binconfig should be dying out, not being extended and shored up like
>>>>> this.
>>>>>
>>>>> I'd also add this patch is buggy, its pure luck that update-alternatives
>>>>> is available at rootfs generation time since its not in a visible
>>>>> dependency.
>>>>>
>>>>> So going forward I'd like to see patches which simply delete binconfig
>>>>> scripts. Where there isn't a .pc alternative we should be adding them
>>>>> and pushing them upstream.
>>>> Did you mean we'd better remove all *-config scripts, insteaded by
>>>> providing .pc files, and send the changes to all upstreams providing and
>>>> using *-config? That seems a huge work and we need co-operate with a lot
>>>> of projects.
>>> Basically, yes, that is what I mean. I might be wrong but I don't think
>>> there are that many projects which don't ship .pc files now and just
>>> have a binconfig as a backup.
>> Yes, I also noticed that many of them are providing .pc files as well as
>> binconfig as a backup, so I think there must be reasons binconfig
>> remained in their projects, that might be for compliable considering,
>> so I am not sure they would like to remove them from their projects, but
>> I can try to ping them. Nevertheless, the conflicts still exist, we just
>> leave them here so far?
> I'm thinking we should start deleting the -config files at do_install
> time where we know a good .pc file exists and remove the binconfig
> inherit. If this causes any problem in software using the package, we
> should fix those to use pkgconfig.
>
> Over time the conflicts will stop existing since the binconfig class
> will not be used anywhere.
Yes, that's a feasible solution, but it needs a lot of testing works, 
unfortunately, I am a little busy with my daily work recently and cant 
handle it parallelly, so I'd like to file a bug in Yocto, see if anybody 
like to take it, or I will do it when I can tear myself away from work 
later.

//Ming Liu
>
> Cheers,
>
> Richard
>
>
>
>
>
Ming Liu - April 9, 2014, 10:07 a.m.
On 04/09/2014 06:01 PM, Ming Liu wrote:
> On 04/09/2014 05:42 PM, Richard Purdie wrote:
>> On Wed, 2014-04-09 at 14:41 +0800, Ming Liu wrote:
>>> On 04/08/2014 06:03 PM, Richard Purdie wrote:
>>>> On Tue, 2014-04-08 at 10:27 +0800, Ming Liu wrote:
>>>>> On 04/07/2014 07:36 PM, Richard Purdie wrote:
>>>>>> On Mon, 2014-04-07 at 19:27 +0800, Ming Liu wrote:
>>>>>>> In most cases binconfig files conflict among multilib packages, 
>>>>>>> to avoid
>>>>>>> that, use update-alternatives link *-config from real path with a
>>>>>>> PACKAGE_ARCH suffix.
>>>>>>>
>>>>>>> Signed-off-by: Ming Liu <ming.liu@windriver.com>
>>>>>>> ---
>>>>>>>     meta/classes/binconfig.bbclass | 65 
>>>>>>> ++++++++++++++++++++++++++++++++++++------
>>>>>>>     1 file changed, 56 insertions(+), 9 deletions(-)
>>>>>> This isn't going in, its complex and supports a minority use case.
>>>>>> binconfig should be dying out, not being extended and shored up like
>>>>>> this.
>>>>>>
>>>>>> I'd also add this patch is buggy, its pure luck that 
>>>>>> update-alternatives
>>>>>> is available at rootfs generation time since its not in a visible
>>>>>> dependency.
>>>>>>
>>>>>> So going forward I'd like to see patches which simply delete 
>>>>>> binconfig
>>>>>> scripts. Where there isn't a .pc alternative we should be adding 
>>>>>> them
>>>>>> and pushing them upstream.
>>>>> Did you mean we'd better remove all *-config scripts, insteaded by
>>>>> providing .pc files, and send the changes to all upstreams 
>>>>> providing and
>>>>> using *-config? That seems a huge work and we need co-operate with 
>>>>> a lot
>>>>> of projects.
>>>> Basically, yes, that is what I mean. I might be wrong but I don't 
>>>> think
>>>> there are that many projects which don't ship .pc files now and just
>>>> have a binconfig as a backup.
>>> Yes, I also noticed that many of them are providing .pc files as 
>>> well as
>>> binconfig as a backup, so I think there must be reasons binconfig
>>> remained in their projects, that might be for compliable considering,
>>> so I am not sure they would like to remove them from their projects, 
>>> but
>>> I can try to ping them. Nevertheless, the conflicts still exist, we 
>>> just
>>> leave them here so far?
>> I'm thinking we should start deleting the -config files at do_install
>> time where we know a good .pc file exists and remove the binconfig
>> inherit. If this causes any problem in software using the package, we
>> should fix those to use pkgconfig.
>>
>> Over time the conflicts will stop existing since the binconfig class
>> will not be used anywhere.
> Yes, that's a feasible solution, but it needs a lot of testing works, 
> unfortunately, I am a little busy with my daily work recently and cant 
> handle it parallelly, so I'd like to file a bug in Yocto, see if 
> anybody like to take it, or I will do it when I can tear myself away 
> from work later.
Seems we already have the defect record, and Qi Chen has been working on 
that for a while, see the following:
https://bugzilla.yoctoproject.org/show_bug.cgi?id=2453

//Ming Liu
>
> //Ming Liu
>>
>> Cheers,
>>
>> Richard
>>
>>
>>
>>
>>
>
Richard Purdie - April 9, 2014, 10:08 a.m.
On Wed, 2014-04-09 at 18:01 +0800, Ming Liu wrote:
> On 04/09/2014 05:42 PM, Richard Purdie wrote:
> > On Wed, 2014-04-09 at 14:41 +0800, Ming Liu wrote:
> >> On 04/08/2014 06:03 PM, Richard Purdie wrote:
> >>> On Tue, 2014-04-08 at 10:27 +0800, Ming Liu wrote:
> >>>> On 04/07/2014 07:36 PM, Richard Purdie wrote:
> >>>>> On Mon, 2014-04-07 at 19:27 +0800, Ming Liu wrote:
> >>>>>> In most cases binconfig files conflict among multilib packages, to avoid
> >>>>>> that, use update-alternatives link *-config from real path with a
> >>>>>> PACKAGE_ARCH suffix.
> >>>>>>
> >>>>>> Signed-off-by: Ming Liu <ming.liu@windriver.com>
> >>>>>> ---
> >>>>>>     meta/classes/binconfig.bbclass | 65 ++++++++++++++++++++++++++++++++++++------
> >>>>>>     1 file changed, 56 insertions(+), 9 deletions(-)
> >>>>> This isn't going in, its complex and supports a minority use case.
> >>>>> binconfig should be dying out, not being extended and shored up like
> >>>>> this.
> >>>>>
> >>>>> I'd also add this patch is buggy, its pure luck that update-alternatives
> >>>>> is available at rootfs generation time since its not in a visible
> >>>>> dependency.
> >>>>>
> >>>>> So going forward I'd like to see patches which simply delete binconfig
> >>>>> scripts. Where there isn't a .pc alternative we should be adding them
> >>>>> and pushing them upstream.
> >>>> Did you mean we'd better remove all *-config scripts, insteaded by
> >>>> providing .pc files, and send the changes to all upstreams providing and
> >>>> using *-config? That seems a huge work and we need co-operate with a lot
> >>>> of projects.
> >>> Basically, yes, that is what I mean. I might be wrong but I don't think
> >>> there are that many projects which don't ship .pc files now and just
> >>> have a binconfig as a backup.
> >> Yes, I also noticed that many of them are providing .pc files as well as
> >> binconfig as a backup, so I think there must be reasons binconfig
> >> remained in their projects, that might be for compliable considering,
> >> so I am not sure they would like to remove them from their projects, but
> >> I can try to ping them. Nevertheless, the conflicts still exist, we just
> >> leave them here so far?
> > I'm thinking we should start deleting the -config files at do_install
> > time where we know a good .pc file exists and remove the binconfig
> > inherit. If this causes any problem in software using the package, we
> > should fix those to use pkgconfig.
> >
> > Over time the conflicts will stop existing since the binconfig class
> > will not be used anywhere.
> Yes, that's a feasible solution, but it needs a lot of testing works, 
> unfortunately, I am a little busy with my daily work recently and cant 
> handle it parallelly, so I'd like to file a bug in Yocto, see if anybody 
> like to take it, or I will do it when I can tear myself away from work 
> later.

Agreed, I'm not asking you personally to do all of this, just suggesting
that ultimately this is the route we need to take.

Cheers,

Richard
Richard Purdie - April 9, 2014, 12:50 p.m.
On Wed, 2014-04-09 at 18:07 +0800, Ming Liu wrote:
> On 04/09/2014 06:01 PM, Ming Liu wrote:
> > On 04/09/2014 05:42 PM, Richard Purdie wrote:
> >> On Wed, 2014-04-09 at 14:41 +0800, Ming Liu wrote:
> >>> On 04/08/2014 06:03 PM, Richard Purdie wrote:
> >>>> On Tue, 2014-04-08 at 10:27 +0800, Ming Liu wrote:
> >>>>> On 04/07/2014 07:36 PM, Richard Purdie wrote:
> >>>>>> On Mon, 2014-04-07 at 19:27 +0800, Ming Liu wrote:
> >>>>>>> In most cases binconfig files conflict among multilib packages, 
> >>>>>>> to avoid
> >>>>>>> that, use update-alternatives link *-config from real path with a
> >>>>>>> PACKAGE_ARCH suffix.
> >>>>>>>
> >>>>>>> Signed-off-by: Ming Liu <ming.liu@windriver.com>
> >>>>>>> ---
> >>>>>>>     meta/classes/binconfig.bbclass | 65 
> >>>>>>> ++++++++++++++++++++++++++++++++++++------
> >>>>>>>     1 file changed, 56 insertions(+), 9 deletions(-)
> >>>>>> This isn't going in, its complex and supports a minority use case.
> >>>>>> binconfig should be dying out, not being extended and shored up like
> >>>>>> this.
> >>>>>>
> >>>>>> I'd also add this patch is buggy, its pure luck that 
> >>>>>> update-alternatives
> >>>>>> is available at rootfs generation time since its not in a visible
> >>>>>> dependency.
> >>>>>>
> >>>>>> So going forward I'd like to see patches which simply delete 
> >>>>>> binconfig
> >>>>>> scripts. Where there isn't a .pc alternative we should be adding 
> >>>>>> them
> >>>>>> and pushing them upstream.
> >>>>> Did you mean we'd better remove all *-config scripts, insteaded by
> >>>>> providing .pc files, and send the changes to all upstreams 
> >>>>> providing and
> >>>>> using *-config? That seems a huge work and we need co-operate with 
> >>>>> a lot
> >>>>> of projects.
> >>>> Basically, yes, that is what I mean. I might be wrong but I don't 
> >>>> think
> >>>> there are that many projects which don't ship .pc files now and just
> >>>> have a binconfig as a backup.
> >>> Yes, I also noticed that many of them are providing .pc files as 
> >>> well as
> >>> binconfig as a backup, so I think there must be reasons binconfig
> >>> remained in their projects, that might be for compliable considering,
> >>> so I am not sure they would like to remove them from their projects, 
> >>> but
> >>> I can try to ping them. Nevertheless, the conflicts still exist, we 
> >>> just
> >>> leave them here so far?
> >> I'm thinking we should start deleting the -config files at do_install
> >> time where we know a good .pc file exists and remove the binconfig
> >> inherit. If this causes any problem in software using the package, we
> >> should fix those to use pkgconfig.
> >>
> >> Over time the conflicts will stop existing since the binconfig class
> >> will not be used anywhere.
> > Yes, that's a feasible solution, but it needs a lot of testing works, 
> > unfortunately, I am a little busy with my daily work recently and cant 
> > handle it parallelly, so I'd like to file a bug in Yocto, see if 
> > anybody like to take it, or I will do it when I can tear myself away 
> > from work later.
> Seems we already have the defect record, and Qi Chen has been working on 
> that for a while, see the following:
> https://bugzilla.yoctoproject.org/show_bug.cgi?id=2453

That bug suggests we have .pc files for all -config files. We would
therefore next need to follow through and remove all the -config files
entirely and just rely on the .pc files. We should open an enhancement
request for that.

Cheers,

Richard

Patch

diff --git a/meta/classes/binconfig.bbclass b/meta/classes/binconfig.bbclass
index 7158c8c..c5503b7 100644
--- a/meta/classes/binconfig.bbclass
+++ b/meta/classes/binconfig.bbclass
@@ -1,4 +1,4 @@ 
-FILES_${PN}-dev += "${bindir}/*-config"
+FILES_${PN}-dev += "${bindir}/*-config.${PACKAGE_ARCH}"
  
 # The namespaces can clash here hence the two step replace
 def get_binconfig_mangle(d):
@@ -31,14 +31,21 @@  BINCONFIG_GLOB ?= "*-config"
 PACKAGE_PREPROCESS_FUNCS += "binconfig_package_preprocess"
 
 binconfig_package_preprocess () {
-	for config in `find ${PKGD} -name '${BINCONFIG_GLOB}'`; do
-		sed -i \
-		    -e 's:${STAGING_BASELIBDIR}:${base_libdir}:g;' \
-		    -e 's:${STAGING_LIBDIR}:${libdir}:g;' \
-		    -e 's:${STAGING_INCDIR}:${includedir}:g;' \
-		    -e 's:${STAGING_DATADIR}:${datadir}:' \
-		    -e 's:${STAGING_DIR_HOST}${prefix}:${prefix}:' \
-                    $config
+	for config in `find ${PKGD}${bindir} -name '${BINCONFIG_GLOB}'`; do
+		if [ -h $config ]; then
+			real_config=`readlink $config`
+			unlink $config
+			( cd ${PKGD}${bindir} ; ln -sf $real_config.${PACKAGE_ARCH} $config.${PACKAGE_ARCH} )
+		else
+			sed -i \
+			    -e 's:${STAGING_BASELIBDIR}:${base_libdir}:g;' \
+			    -e 's:${STAGING_LIBDIR}:${libdir}:g;' \
+			    -e 's:${STAGING_INCDIR}:${includedir}:g;' \
+			    -e 's:${STAGING_DATADIR}:${datadir}:' \
+			    -e 's:${STAGING_DIR_HOST}${prefix}:${prefix}:' \
+			    $config
+			mv $config $config.${PACKAGE_ARCH}
+		fi
 	done
 	for lafile in `find ${PKGD} -name "*.la"` ; do
 		sed -i \
@@ -51,6 +58,46 @@  binconfig_package_preprocess () {
 	done	    
 }
 
+BINCONFIG_PRIORITY ?= "${@int(d.getVar('PV',1).split('-')[0].split('+')[0].split('.')[0]) * 10000 + \
+                       int(d.getVar('PV',1).split('-')[0].split('+')[0].split('.')[1]) * 100 + \
+                       int(d.getVar('PV',1).split('-')[0].split('+')[0].split('.')[-1])}"
+
+PACKAGESPLITFUNCS_prepend = "populate_packages_binconfig "
+
+#
+# Fix binconfig conflicts among multilib packages
+#
+python populate_packages_binconfig () {
+    import os, glob
+
+    pkg = d.getVar('PN', True) + '-dev'
+    dvar = d.getVar('PKGD', True)
+    bindir = d.getVar('bindir', True)
+    binconfig_glob = d.getVar('BINCONFIG_GLOB', True)
+    binconfig_priority = d.getVar('BINCONFIG_PRIORITY', True)
+    binconfig_setup_links = ""
+    binconfig_remove_links = ""
+    for file in glob.glob(dvar + bindir + os.sep + binconfig_glob + '.' + d.getVar('PACKAGE_ARCH', True)):
+        binconfig_target = os.path.basename(file)
+        binconfig_name = binconfig_target[:binconfig_target.find('.')]
+        binconfig_link = bindir + os.sep + binconfig_name
+        binconfig_setup_links += '\tupdate-alternatives --install %s %s %s %s\n' % (binconfig_link, binconfig_name, binconfig_target, binconfig_priority)
+        binconfig_remove_links += '\tupdate-alternatives --remove  %s %s\n' % (binconfig_name, binconfig_target)
+
+        if binconfig_setup_links:
+            provider = d.getVar('VIRTUAL-RUNTIME_update-alternatives', True)
+            if provider:
+                d.appendVar('RDEPENDS_%s' % pkg, ' ' + d.getVar('MLPREFIX') + provider)
+
+            postinst = d.getVar('pkg_postinst_%s' % pkg, True) or '#!/bin/sh\n'
+            postinst += binconfig_setup_links
+            d.setVar('pkg_postinst_%s' % pkg, postinst)
+
+            postrm = d.getVar('pkg_postrm_%s' % pkg, True) or '#!/bin/sh\n'
+            postrm += binconfig_remove_links
+            d.setVar('pkg_postrm_%s' % pkg, postrm)
+}
+
 SYSROOT_PREPROCESS_FUNCS += "binconfig_sysroot_preprocess"
 
 binconfig_sysroot_preprocess () {