Prechádzať zdrojové kódy

Fix use of config fragments

This is a Python port of the regular expressions used by
merge_config.sh to parse config fragments. The assembled config is
stored temporary in memory.

Signed-off-by: Alexander Vickberg <wickbergster@gmail.com>
Alexander Vickberg 5 rokov pred
rodič
commit
1c193bb9f7
1 zmenil súbory, kde vykonal 22 pridanie a 1 odobranie
  1. 22 1
      recipes-support/swupdate/swupdate.inc

+ 22 - 1
recipes-support/swupdate/swupdate.inc

@@ -79,6 +79,8 @@ def find_cfgs(d):
     return [s for s in src_patches(d, True) if s.endswith('.cfg')]
 
 python () {
+    import re
+
     try:
         defconfig = bb.fetch2.localpath('file://defconfig', d)
     except bb.fetch2.FetchError:
@@ -89,9 +91,28 @@ python () {
     except IOError:
         return
 
-    features = configfile.readlines()
+    features = configfile.read()
     configfile.close()
 
+    for current_fragment in find_cfgs(d):
+        try:
+            fragment_fd = open(current_fragment)
+        except IOError:
+            continue
+
+        fragment = fragment_fd.read()
+        fragment_fd.close()
+
+        fragment_search = re.findall('^(?:# )?(CONFIG_[a-zA-Z0-9_]*)[= ].*\n?', fragment, re.MULTILINE)
+
+        for feature in fragment_search:
+            features = re.sub("^(?:# )?" + feature + "[= ].*\n?", "", features, flags=re.MULTILINE)
+
+        features = features + fragment
+
+    features = features.splitlines(True)
+
+
     depends = d.getVar('DEPENDS', False)
 
     if 'CONFIG_REMOTE_HANDLER=y\n' in features: