<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Feb 1, 2013 at 4:00 AM,  <span dir="ltr">&lt;<a href="mailto:Qi.Chen@windriver.com" target="_blank">Qi.Chen@windriver.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Chen Qi &lt;<a href="mailto:Qi.Chen@windriver.com" target="_blank">Qi.Chen@windriver.com</a>&gt;<br>
<br>
Add config fragments to busybox.<br>
<br>
Both the implementation and the use case are similar to yocto kernel&#39;s<br>
configuration fragments.<br></blockquote><div><br></div><div>I can fairly easily tweak the configuration parts of the kern-tools to handle this</div><div>use case as well. That would allow us to re-use the kernel&#39;s merge_config.sh</div>
<div>script (with a minor dependency change) and save some duplicated code. It</div><div>also gets you the advantage that you can consolidate configuration fragments</div><div>outside of any build system, which isn&#39;t as critical here, but something that </div>
<div style>is used quite a bit during kernel testing.</div><div style><br></div><div style>To be clear, I&#39;m not talking about the entire kern-tools here, just the config parts.</div><div style><br></div><div style>Cheers,</div>
<div style><br></div><div style>Bruce</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
[YOCTO #3379]<br>
<br>
Signed-off-by: Chen Qi &lt;<a href="mailto:Qi.Chen@windriver.com" target="_blank">Qi.Chen@windriver.com</a>&gt;<br>
---<br>
<div> meta/recipes-core/busybox/busybox.inc |   45 +++++++++++++++++++++++++++++++++<br>
 1 file changed, 45 insertions(+)<br>
<br>
</div>diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc<br>
index 972e7d0..66044f8 100644<br>
--- a/meta/recipes-core/busybox/busybox.inc<br>
+++ b/meta/recipes-core/busybox/busybox.inc<br>
@@ -112,8 +112,53 @@ do_prepare_config () {<br>
        fi<br>
 }<br>
<br>
+# returns all the elements from the src uri that are .cfg files<br>
+def find_cfgs(d):<br>
+    sources=src_patches(d, True)<br>
+    sources_list=[]<br>
+    for s in sources:<br>
+        if s.endswith(&#39;.cfg&#39;):<br>
+            sources_list.append(s)<br>
+<br>
+    return sources_list<br>
+<br>
+# Merge config fragments<br>
+# All config fragments for busybox should end with .cfg<br>
+do_merge_config() {<br>
+        SED_CONFIG_EXP=&quot;s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p&quot;<br>
+        MERGE_LIST=&quot;${@&quot; &quot;.join(find_cfgs(d))}&quot;<br>
+        if [ -n &quot;$MERGE_LIST&quot; ]; then<br>
+                # Make a temp file, merge .config and .cfg files into it<br>
+                TMP_FILE=`mktemp .tmp.config.XXXXXXXX`<br>
+                cp .config $TMP_FILE<br>
+                for MERGE_FILE in $MERGE_LIST; do<br>
+                        CFG_LIST=`sed -n &quot;${SED_CONFIG_EXP}&quot; $MERGE_FILE`<br>
+                        for CFG in $CFG_LIST ; do<br>
+                                grep -q -w $CFG $TMP_FILE<br>
+                                if [ $? -eq 0 ] ; then<br>
+                                        PREV_VAL=`grep -w $CFG $TMP_FILE`<br>
+                                        NEW_VAL=`grep -w $CFG $MERGE_FILE`<br>
+                                        if [ &quot;x$PREV_VAL&quot; != &quot;x$NEW_VAL&quot; ] ; then<br>
+                                                echo Value of $CFG is redefined by fragment $MERGE_FILE:<br>
+                                                echo Previous  value: $PREV_VAL<br>
+                                                echo New value:       $NEW_VAL<br>
+                                                echo<br>
+                                        fi<br>
+                                        sed -i &quot;/$CFG[ =]/d&quot; $TMP_FILE<br>
+                                fi<br>
+                        done<br>
+                        echo &gt;&gt; $TMP_FILE<br>
+                        cat $MERGE_FILE &gt;&gt; $TMP_FILE<br>
+                done<br>
+                # Copy the temp file to .config, do some cleanup<br>
+               cp $TMP_FILE .config<br>
+               rm $TMP_FILE<br>
+        fi<br>
+}<br>
+<br>
 do_configure () {<br>
        do_prepare_config<br>
+       do_merge_config<br>
        cml1_do_configure<br>
<div><div> }<br>
<br>
--<br>
1.7.9.5<br>
<br>
<br>
_______________________________________________<br>
Openembedded-core mailing list<br>
<a href="mailto:Openembedded-core@lists.openembedded.org" target="_blank">Openembedded-core@lists.openembedded.org</a><br>
<a href="http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core" target="_blank">http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>&quot;Thou shalt not follow the NULL pointer, for chaos and madness await thee at its end&quot;
</div></div>