All of lore.kernel.org
 help / color / mirror / Atom feed
From: <Qi.Chen@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Cc: Zhenfeng.Zhao@windriver.com
Subject: [PATCH 1/1] busybox: add config fragments
Date: Fri, 1 Feb 2013 17:00:22 +0800	[thread overview]
Message-ID: <b2319aaf09ba1dccdcd58cf067a1b0b1dd4ada93.1359708915.git.Qi.Chen@windriver.com> (raw)
In-Reply-To: <cover.1359708915.git.Qi.Chen@windriver.com>

From: Chen Qi <Qi.Chen@windriver.com>

Add config fragments to busybox.

Both the implementation and the use case are similar to yocto kernel's
configuration fragments.

[YOCTO #3379]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 meta/recipes-core/busybox/busybox.inc |   45 +++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc
index 972e7d0..66044f8 100644
--- a/meta/recipes-core/busybox/busybox.inc
+++ b/meta/recipes-core/busybox/busybox.inc
@@ -112,8 +112,53 @@ do_prepare_config () {
 	fi
 }
 
+# returns all the elements from the src uri that are .cfg files
+def find_cfgs(d):
+    sources=src_patches(d, True)
+    sources_list=[]
+    for s in sources:
+        if s.endswith('.cfg'):
+            sources_list.append(s)
+
+    return sources_list
+
+# Merge config fragments
+# All config fragments for busybox should end with .cfg
+do_merge_config() {
+        SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p"
+        MERGE_LIST="${@" ".join(find_cfgs(d))}"
+        if [ -n "$MERGE_LIST" ]; then
+                # Make a temp file, merge .config and .cfg files into it
+                TMP_FILE=`mktemp .tmp.config.XXXXXXXX`
+                cp .config $TMP_FILE
+                for MERGE_FILE in $MERGE_LIST; do
+                        CFG_LIST=`sed -n "${SED_CONFIG_EXP}" $MERGE_FILE`
+                        for CFG in $CFG_LIST ; do
+                                grep -q -w $CFG $TMP_FILE
+                                if [ $? -eq 0 ] ; then
+                                        PREV_VAL=`grep -w $CFG $TMP_FILE`
+                                        NEW_VAL=`grep -w $CFG $MERGE_FILE`
+                                        if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
+                                                echo Value of $CFG is redefined by fragment $MERGE_FILE:
+                                                echo Previous  value: $PREV_VAL
+                                                echo New value:       $NEW_VAL
+                                                echo
+                                        fi
+                                        sed -i "/$CFG[ =]/d" $TMP_FILE
+                                fi
+                        done
+                        echo >> $TMP_FILE
+                        cat $MERGE_FILE >> $TMP_FILE
+                done
+                # Copy the temp file to .config, do some cleanup
+		cp $TMP_FILE .config
+		rm $TMP_FILE
+        fi
+}
+
 do_configure () {
 	do_prepare_config
+	do_merge_config
 	cml1_do_configure
 }
 
-- 
1.7.9.5




  reply	other threads:[~2013-02-01  9:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-01  9:00 [PATCH 0/1] busybox: add config fragments Qi.Chen
2013-02-01  9:00 ` Qi.Chen [this message]
2013-02-01 14:18   ` [PATCH 1/1] " Bruce Ashfield
2013-02-01 18:56     ` Saul Wold
2013-02-01 19:08       ` Bruce Ashfield
2013-02-05  3:01         ` ChenQi
2013-02-05  6:42         ` ChenQi
2013-02-05 16:29           ` Bruce Ashfield
2013-02-12 13:21             ` Richard Purdie
2013-02-12 14:06               ` Bruce Ashfield
2013-02-12 15:32                 ` Richard Purdie
2013-02-12 16:50                   ` Bruce Ashfield
2013-02-13 16:53                     ` Richard Purdie
2013-02-13 16:59                       ` Bruce Ashfield

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2319aaf09ba1dccdcd58cf067a1b0b1dd4ada93.1359708915.git.Qi.Chen@windriver.com \
    --to=qi.chen@windriver.com \
    --cc=Zhenfeng.Zhao@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.