Skip to contentSkip to conversation

binconfig.bbclass optional last slash handling

PATCH Superseded Denis 'GNUtoo' Carikli 3 participants 4 messages Nov 13, 2010 – Nov 24, 2010

lore
Share & tools
lore
#0 lore raw

hi,

Martin Jansa (JaMa on irc(#oe on Freenode))told me that libmikmod-config --libs had the following output:
-L/usr/lib -lmikmod -ldl -lm
Which is obviously problematic,because it was the libmikmod-config from sysroot which prevented some compilation of packages like supertux-qvga(fixes like 9a97090b98ee4177b806c305168473562580d0c7 , which resulted from a misunderstanding between me and Martin Jansa are wrong because they only workaround the problem instead of fixing the real issue, which is discussed here)
so I digged into it and here's what I found:

Here's the beginning of libmikmod-config as generated(and before the binconfig mangling):

Quoted 5 lines

#! /bin/sh

prefix=/usr
exec_prefix=/usr
exec_prefix_set=no

Then because in libmikmod, binconfig is inherited, the following is called:

binconfig_sysroot_preprocess () {
for config in find ${S} -name '${BINCONFIG_GLOB}'; do

    configname=`basename $config`
    install -d ${SYSROOT_DESTDIR}${STAGING_BINDIR_CROSS}
    cat $config | sed ${@get_binconfig_mangle(d)} >  ${SYSROOT_DESTDIR}${STAGING_BINDIR_CROSS}/$configname
    chmod u+x ${SYSROOT_DESTDIR}${STAGING_BINDIR_CROSS}/$configname

done

with get_binconfig_mangle beeing the following function:
# The namespaces can clash here hence the two step replace def get_binconfig_mangle(d):
s = "-e ''"
if not bb.data.inherits_class('native', d):

    optional_quote = r"\(\"\?\)"
    s += " -e 's:=%s${libdir}:=\\1OELIBDIR:;'" % optional_quote
    s += " -e 's:=%s${includedir}:=\\1OEINCDIR:;'" % optional_quote
    s += " -e 's:=%s${datadir}:=\\1OEDATADIR:'" % optional_quote
    s += " -e 's:=%s${prefix}/:=\\1OEPREFIX/:'" % optional_quote
    s += " -e 's:=%s${exec_prefix}/:=\\1OEEXECPREFIX/:'" % optional_quote
    s += " -e 's:-L${libdir}:-LOELIBDIR:;'"
    s += " -e 's:-I${includedir}:-IOEINCDIR:;'"
    s += " -e 's:OELIBDIR:${STAGING_LIBDIR}:;'"
    s += " -e 's:OEINCDIR:${STAGING_INCDIR}:;'"
    s += " -e 's:OEDATADIR:${STAGING_DATADIR}:'"
    s += " -e 's:OEPREFIX:${STAGING_DIR_HOST}${prefix}:'"
    s += " -e 's:OEEXECPREFIX:${STAGING_DIR_HOST}${exec_prefix}:'"
    s += " -e 's:-I${WORKDIR}:-I${STAGING_INCDIR}:'"
    s += " -e 's:-L${WORKDIR}:-L${STAGING_LIBDIR}:'"
    if bb.data.getVar("OE_BINCONFIG_EXTRA_MANGLE", d):
        s += bb.data.getVar("OE_BINCONFIG_EXTRA_MANGLE", d)

return s

which turns into:
cat libmikmod-config | sed
-e ''
-e 's:=\("\?\)/usr/lib:=\1OELIBDIR:;'
-e 's:=\("\?\)/usr/include:=\1OEINCDIR:;'
-e 's:=\("\?\)/usr/share:=\1OEDATADIR:'
-e 's:=\("\?\)/usr/:=\1OEPREFIX/:'
-e 's:=\("\?\)/usr/:=\1OEEXECPREFIX/:'
-e 's:-L/usr/lib:-LOELIBDIR:;'
-e 's:-I/usr/include:-IOEINCDIR:;'
-e
's:OELIBDIR:/home/gnutoo/embedded/oe/oetmps/nokia900/sysroots/armv7a-oe-linux-gnueabi/usr/lib:;'
-e
's:OEINCDIR:/home/gnutoo/embedded/oe/oetmps/nokia900/sysroots/armv7a-oe-linux-gnueabi/usr/include:;'
-e
's:OEDATADIR:/home/gnutoo/embedded/oe/oetmps/nokia900/sysroots/armv7a-oe-linux-gnueabi/usr/share:'
-e
's:OEPREFIX:/home/gnutoo/embedded/oe/oetmps/nokia900/sysroots/armv7a-oe-linux-gnueabi/usr:'
-e
's:OEEXECPREFIX:/home/gnutoo/embedded/oe/oetmps/nokia900/sysroots/armv7a-oe-linux-gnueabi/usr:'
-e 's:-I/home/gnutoo/embedded/oe/oetmps/nokia900/work/armv7a-oe-linux-gnueabi/libmikmod-3.2.0-beta2-r3:-I/home/gnutoo/embedded/oe/oetmps/nokia900/sysroots/armv7a-oe-linux-gnueabi/usr/include:' -e 's:-L/home/gnutoo/embedded/oe/oetmps/nokia900/work/armv7a-oe-linux-gnueabi/libmikmod-3.2.0-beta2-r3:-L/home/gnutoo/embedded/oe/oetmps/nokia900/sysroots/armv7a-oe-linux-gnueabi/usr/lib:'

let's examine that part : -e 's:=\("\?\)/usr/:=\1OEPREFIX/:'

echo prefix=/usr | sed -e 's:=\("\?\)/usr/:=\1OEPREFIX/:' gives:
prefix=/usr

echo prefix=/usr/ | sed -e 's:=\("\?\)/usr/:=\1OEPREFIX/:' gives:
prefix=OEPREFIX/

we have in the bbclass:
s += " -e 's:=%s${prefix}/:=\\1OEPREFIX/:'" % optional_quote s += " -e 's:=%s${exec_prefix}/:=\\1OEEXECPREFIX/:'" % optional_quote

So, should I make the last slash optional, or should I remove it ?

Making it optional would result in the following code:
optional_slash = r"\(\/\?\)"
s += " -e 's:=%s${prefix}%s:=\\1OEPREFIX/:'" % (optional_quote ,optional_slash) s += " -e 's:=%s${exec_prefix}%s:=\\1OEEXECPREFIX/:'" % (optional_quote ,optional_slash)

Denis.

#1 lore raw

PATCH 1/1 binconfig: use / instead empty prefix/exec_prefix in get_binconfig_mangle

* 952e5e2b7a5c1deefc939594d40b81a71fb16a54 appends / in sed call, but it breaks ie =/usr replacement ie in libmikmod
* using at least / in SLASH_PREFIX/SLASH_EXEC_PREFIX is needed ie for micro distribution where prefix/exec_prefix are empty (/usr collapsed to /)
* thanks to GNUtoo!

---
 classes/binconfig.bbclass |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
classes/binconfig.bbclass +8 -2
index b3b2236..df2c283 100644
@@ -2,14 +2,20 @@ FILES_${PN}-dev += "${bindir}/*-config"
 
 # The namespaces can clash here hence the two step replace
 def get_binconfig_mangle(d):
+	SLASH_PREFIX = "${prefix}"
+	if SLASH_PREFIX is "":
+		SLASH_PREFIX = "/"
+	SLASH_EXEC_PREFIX = "${exec_prefix}"
+	if SLASH_EXEC_PREFIX is "":
+		SLASH_EXEC_PREFIX = "/"
 	s = "-e ''"
 	if not bb.data.inherits_class('native', d):
 		optional_quote = r"\(\"\?\)"
 		s += " -e 's:=%s${libdir}:=\\1OELIBDIR:;'" % optional_quote
 		s += " -e 's:=%s${includedir}:=\\1OEINCDIR:;'" % optional_quote
 		s += " -e 's:=%s${datadir}:=\\1OEDATADIR:'" % optional_quote
-		s += " -e 's:=%s${prefix}/:=\\1OEPREFIX/:'" % optional_quote
-		s += " -e 's:=%s${exec_prefix}/:=\\1OEEXECPREFIX/:'" % optional_quote
+		s += " -e 's:=%s%s:=\\1OEPREFIX:'" % (optional_quote, SLASH_PREFIX)
+		s += " -e 's:=%s%s:=\\1OEEXECPREFIX:'" % (optional_quote, SLASH_EXEC_PREFIX)
 		s += " -e 's:-L${libdir}:-LOELIBDIR:;'"
 		s += " -e 's:-I${includedir}:-IOEINCDIR:;'"
 		s += " -e 's:OELIBDIR:${STAGING_LIBDIR}:;'"
Signature · 1 line
1.7.3.2
#2 lore raw

RFC PATCH v2 1/1 binconfig: use / instead empty prefix/exec_prefix in get_binconfig_mangle

* 952e5e2b7a5c1deefc939594d40b81a71fb16a54 appends / in sed call, but it breaks ie =/usr replacement ie in libmikmod
* using at least / in SLASH_PREFIX/SLASH_EXEC_PREFIX is needed ie for micro distribution where prefix/exec_prefix are empty (/usr collapsed to /)
* prefix and exec_prefix are expanded only in shell environment (after get_binconfig_mangle is returned so to check if it's empty we have to pass them expanded as params)
* don't push this patch it fixes libmikmod with !micro, but in micro it's still broken, because libmikmod-config has empty 'prefix=' which is the case when we normaly don't want to add OEPREFIX (whole point of this patch), but in this case it's needed (let's just fix libmikmod.in)
* thanks to GNUtoo!

---
 classes/binconfig.bbclass |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
classes/binconfig.bbclass +10 -4
index b3b2236..e462083 100644
@@ -1,15 +1,21 @@
 FILES_${PN}-dev += "${bindir}/*-config"
 
 # The namespaces can clash here hence the two step replace
-def get_binconfig_mangle(d):
+def get_binconfig_mangle(d, env_prefix, env_exec_prefix):
+	SLASH_PREFIX = env_prefix
+	if SLASH_PREFIX is "":
+		SLASH_PREFIX = "/"
+	SLASH_EXEC_PREFIX = env_exec_prefix
+	if SLASH_EXEC_PREFIX is "":
+		SLASH_EXEC_PREFIX = "/"
 	s = "-e ''"
 	if not bb.data.inherits_class('native', d):
 		optional_quote = r"\(\"\?\)"
 		s += " -e 's:=%s${libdir}:=\\1OELIBDIR:;'" % optional_quote
 		s += " -e 's:=%s${includedir}:=\\1OEINCDIR:;'" % optional_quote
 		s += " -e 's:=%s${datadir}:=\\1OEDATADIR:'" % optional_quote
-		s += " -e 's:=%s${prefix}/:=\\1OEPREFIX/:'" % optional_quote
-		s += " -e 's:=%s${exec_prefix}/:=\\1OEEXECPREFIX/:'" % optional_quote
+		s += " -e 's:=%s%s:=\\1OEPREFIX:'" % (optional_quote, SLASH_PREFIX)
+		s += " -e 's:=%s%s:=\\1OEEXECPREFIX:'" % (optional_quote, SLASH_EXEC_PREFIX)
 		s += " -e 's:-L${libdir}:-LOELIBDIR:;'"
 		s += " -e 's:-I${includedir}:-IOEINCDIR:;'"
 		s += " -e 's:OELIBDIR:${STAGING_LIBDIR}:;'"
@@ -52,7 +58,7 @@ binconfig_sysroot_preprocess () {
 	for config in `find ${S} -name '${BINCONFIG_GLOB}'`; do
 		configname=`basename $config`
 		install -d ${SYSROOT_DESTDIR}${STAGING_BINDIR_CROSS}
-		cat $config | sed ${@get_binconfig_mangle(d)} > ${SYSROOT_DESTDIR}${STAGING_BINDIR_CROSS}/$configname
+		cat $config | sed ${@get_binconfig_mangle(d, "${prefix}", "${exec_prefix}")} > ${SYSROOT_DESTDIR}${STAGING_BINDIR_CROSS}/$configname
 		chmod u+x ${SYSROOT_DESTDIR}${STAGING_BINDIR_CROSS}/$configname
 	done
 }
Signature · 1 line
1.7.3.2
#3 lore raw

Re: [PATCHv2][RFC] binconfig: use / instead empty prefix/exec_prefix in get_binconfig_mangle

seems fine to me.

Quoted 63 lines · Martin Jansa

* 952e5e2b7a5c1deefc939594d40b81a71fb16a54 appends / in sed call, but it breaks ie =/usr replacement ie in libmikmod
* using at least / in SLASH_PREFIX/SLASH_EXEC_PREFIX is needed ie for micro distribution where prefix/exec_prefix are empty (/usr collapsed to /)
* prefix and exec_prefix are expanded only in shell environment (after get_binconfig_mangle is returned so to check if it's empty we have to pass them expanded as params)
* don't push this patch it fixes libmikmod with !micro, but in micro it's still broken, because libmikmod-config has empty 'prefix=' which is the case when we normaly don't want to add OEPREFIX (whole point of this patch), but in this case it's needed (let's just fix libmikmod.in)
* thanks to GNUtoo!
---
 classes/binconfig.bbclass |   14 ++++++++++----

 1 files changed, 10 insertions(+), 4 deletions(-)
classes/binconfig.bbclass +0 -0
index b3b2236..e462083 100644
@@ -1,15 +1,21 @@

 FILES_${PN}-dev += "${bindir}/*-config"

 # The namespaces can clash here hence the two step replace

classes/binconfig.bbclass +7 -1
-def get_binconfig_mangle(d):
+def get_binconfig_mangle(d, env_prefix, env_exec_prefix):
+       SLASH_PREFIX = env_prefix
+       if SLASH_PREFIX is "":
+               SLASH_PREFIX = "/"
+       SLASH_EXEC_PREFIX = env_exec_prefix
+       if SLASH_EXEC_PREFIX is "":
+               SLASH_EXEC_PREFIX = "/"

       s = "-e ''"
       if not bb.data.inherits_class('native', d):
               optional_quote = r"\(\"\?\)"
               s += " -e 's:=%s${libdir}:=\\1OELIBDIR:;'" % optional_quote
               s += " -e 's:=%s${includedir}:=\\1OEINCDIR:;'" % optional_quote s += " -e 's:=%s${datadir}:=\\1OEDATADIR:'" % optional_quote
-               s += " -e 's:=%s${prefix}/:=\\1OEPREFIX/:'" % optional_quote
-               s += " -e 's:=%s${exec_prefix}/:=\\1OEEXECPREFIX/:'" % optional_quote
+               s += " -e 's:=%s%s:=\\1OEPREFIX:'" % (optional_quote, SLASH_PREFIX)
+               s += " -e 's:=%s%s:=\\1OEEXECPREFIX:'" % (optional_quote, SLASH_EXEC_PREFIX) s += " -e 's:-L${libdir}:-LOELIBDIR:;'"
               s += " -e 's:-I${includedir}:-IOEINCDIR:;'"
               s += " -e 's:OELIBDIR:${STAGING_LIBDIR}:;'"

classes/binconfig.bbclass +0 -0
@@ -52,7 +58,7 @@ binconfig_sysroot_preprocess () {

       for config in find ${S} -name '${BINCONFIG_GLOB}'; do
               configname=basename $config
               install -d ${SYSROOT_DESTDIR}${STAGING_BINDIR_CROSS}
-               cat $config | sed ${@get_binconfig_mangle(d)} > ${SYSROOT_DESTDIR}${STAGING_BINDIR_CROSS}/$configname
+               cat $config | sed ${@get_binconfig_mangle(d, "${prefix}", "${exec_prefix}")} > ${SYSROOT_DESTDIR}${STAGING_BINDIR_CROSS}/$configname chmod u+x ${SYSROOT_DESTDIR}${STAGING_BINDIR_CROSS}/$configname
       done
 }
--
1.7.3.2

_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel