From 21d73b4159d65ec1279ed603bc67f32fb8346f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 28 Aug 2015 17:45:26 +0200 Subject: Reimplement fromfolder script 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 | 10 ------- scripts/fromfolder.py | 71 ++++++++++++++++++++++++++++++++++++++++++++ targets/ryuglab/config_force | 22 ++++++++++++++ 3 files changed, 93 insertions(+), 10 deletions(-) delete mode 100755 scripts/from_folder create mode 100755 scripts/fromfolder.py create mode 100644 targets/ryuglab/config_force diff --git a/scripts/from_folder b/scripts/from_folder deleted file mode 100755 index 8801a48..0000000 --- a/scripts/from_folder +++ /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 index 0000000..d5bb2b3 --- /dev/null +++ b/scripts/fromfolder.py @@ -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 index 0000000..9886c72 --- /dev/null +++ b/targets/ryuglab/config_force @@ -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 -- cgit v1.2.3