]> rtime.felk.cvut.cz Git - linux-conf-perf.git/commitdiff
Reimplement fromfolder script
authorKarel Kočí <cynerd@email.cz>
Fri, 28 Aug 2015 15:45:26 +0000 (17:45 +0200)
committerKarel Kočí <cynerd@email.cz>
Fri, 28 Aug 2015 15:45:26 +0000 (17:45 +0200)
Removing configuration options from configuration file according to
definition folder. New implementation allows to specify required
configuration options that shouldn't be removed in any case.

scripts/from_folder [deleted file]
scripts/fromfolder.py [new file with mode: 0755]
targets/ryuglab/config_force [new file with mode: 0644]

diff --git a/scripts/from_folder b/scripts/from_folder
deleted file mode 100755 (executable)
index 8801a48..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/bash
-
-FOLDER=linux/kernel
-
-CONF=`find $FOLDER -name Kconfig | xargs grep -e ^config | cut -d ' ' -f2`
-
-REG=`echo $CONF | tr " " "|" | sed 's/^/\(/' | sed 's/$/\)/'`
-
-#egrep "$REG" $1
-egrep -v "$REG" $1 > $2
diff --git a/scripts/fromfolder.py b/scripts/fromfolder.py
new file mode 100755 (executable)
index 0000000..d5bb2b3
--- /dev/null
@@ -0,0 +1,71 @@
+#!/usr/bin/env python3
+import os
+import sys
+import re
+from conf import conf
+from conf import sf
+
+def loadfromKconfig(file):
+       found = set()
+       for ln in open(file):
+               if re.search('^config', ln):
+                       name = ln[7:].rstrip()
+                       found.add(name)
+       return found
+
+def loadfromfolder(folder):
+       found = set()
+       for l in os.listdir(folder):
+               if os.path.isdir(folder + '/' + l):
+                       found = found | loadfromfolder(folder + '/' + l)
+               elif os.path.isfile(folder + '/' + l) and re.search('Kconfig', l):
+                       found =  found | loadfromKconfig(folder + '/' + l)
+       return found
+
+def removefrom(file, outfile, removelist):
+       alllines = []
+       for ln in open(file):
+               alllines.append(ln.rstrip())
+       
+       for rl in removelist:
+               for ln in alllines:
+                       if re.search('^CONFIG_' + rl + '=', ln):
+                               print('removing ' + ln)
+                               alllines.remove(ln)
+       
+       with open(outfile, 'w') as f:
+               for ln in alllines:
+                       f.write(ln + '\n')
+       
+#################################################################################
+
+# TODO propper argument parsing
+if __name__ == '__main__':
+       folder = sys.argv[1]
+       inputfile = sys.argv[2]
+       outputfile = sys.argv[3]
+       if not len(sys.argv) < 5:
+               exceptfile = sys.argv[4]
+
+       exceptconf = set()
+       if os.path.isfile(exceptfile):
+               for ln in open(exceptfile):
+                       lns = ln.rstrip()
+                       if lns:
+                               exceptconf.add(lns)
+
+       rem = loadfromfolder(sf(conf.linux_sources + '/' + folder))
+
+       for ec in exceptconf:
+               rrlist = []
+               for r in rem:
+                       if re.match(ec, r):
+                               print('except ' + r)
+                               rrlist.append(r)
+               for r in rrlist:
+                       try:
+                               rem.remove(r)
+                       except KeyError:
+                               pass
+
+       removefrom(inputfile, outputfile, rem)
diff --git a/targets/ryuglab/config_force b/targets/ryuglab/config_force
new file mode 100644 (file)
index 0000000..9886c72
--- /dev/null
@@ -0,0 +1,22 @@
+BLK_DEV_INITRD
+INITRAMFS_COMPRESSION_*
+RD_GZIP
+
+PPC_MPC52xx
+PPC_MPC5200_SIMPLE
+SERIAL_CORE
+SERIAL_CORE_CONSOLE
+SERIAL_MPC52xx
+SERIAL_MPC52xx_CONSOLE
+
+TTY
+PROC_FS
+PRINTK
+
+BINFMT_SCRIPT
+DEVTMPFS
+HIGH_RES_TIMERS
+MULTIUSER
+
+FUTEX
+CONFIG_PREEMPT_RT_FULL