SOURCES: kernel-config.awk (NEW) - kernel-config.py replacement written in ...
sparky
sparky at pld-linux.org
Thu Sep 18 03:16:17 CEST 2008
Author: sparky Date: Thu Sep 18 01:16:17 2008 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- kernel-config.py replacement written in awk
- features:
-- pure awk, no need to BR: python, which may be problematic sometimes
-- over 40 times faster than python version (lacks value checking tho)
-- prints lots of useful warnings, like those:
kernel-multiarch.config (2647): HW_RANDOM_VIRTIO=m should have explicit ` all='
kernel-i386.config (60): CONFIG_NO_HZ already defined in: kernel-multiarch.config (103)
---- Files affected:
SOURCES:
kernel-config.awk (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/kernel-config.awk
diff -u /dev/null SOURCES/kernel-config.awk:1.1
--- /dev/null Thu Sep 18 03:16:18 2008
+++ SOURCES/kernel-config.awk Thu Sep 18 03:16:11 2008
@@ -0,0 +1,104 @@
+# A script for building kernel config from multiarch config file.
+# It also has some file merging facilities.
+#
+# usage:
+# awk -v arch=%{_target_base_arch} -f path/to/kernel-config.awk \
+# kernel-multiarch.config kernel-%{arch}.config kernel-%{some_feature}.config \
+# > .config
+#
+# TODO:
+# - check value correctness, should allow only:
+# y, m, n, -[0-9]+, 0x[0-9A-Fa-f]+, ".*"
+# - smarter arch split, there could be strings with spaces
+# ( kernel-config.py does not suppoty it either )
+# - use as many warnings as possible, we want our configs to be clean
+# - allow more multiarch configs
+
+function warn( msg ) {
+ print FILENAME " (" FNR "): " msg > "/dev/stderr"
+}
+
+BEGIN {
+ if ( ! arch ) {
+ warn( "arch= must be specified" )
+ exit 1
+ }
+ firstfile = 1
+}
+
+{
+ # remember first file name
+ if ( ! file )
+ file = FILENAME
+
+ else if ( file != FILENAME ) { # second and following files
+ if ( match( $0, /CONFIG_[A-Za-z0-9_-]+/ ) ) {
+ option = substr( $0, RSTART, RLENGTH )
+ if ( $0 ~ "^" option "=.+$" || $0 ~ "^# " option " is not set$" ) {
+ if ( option in outputArray )
+ warn( option " already defined in: " outputArray[ option ] )
+ else {
+ print
+ outputArray[ option ] = FILENAME " (" FNR ")"
+ }
+ } else {
+ if ( ! /^#/ )
+ warn( "Incorrect line: " $0 )
+ }
+ } else if ( ! /^\s*$/ && ! /^#/ ) {
+ warn( "Incorrect line: " $0 )
+ }
+ next
+ }
+}
+
+# multiarch file proxessing
+
+/^#/ || /^\s*$/ {
+ next
+}
+
+/^CONFIG_/ {
+ warn( "Options should not start with CONFIG_" )
+ gsub( /^CONFIG_/, "" )
+}
+
+{
+ option = $1
+ line = $0
+ if ( option ~ /=/ ) {
+ warn( $0 " should have explicit ` all='" )
+ gsub( /=.*$/, "", option )
+ gsub( /^[^=]*=/, "", line )
+ line = "all=" line
+ } else {
+ gsub( "^" option, "", line )
+ }
+ split( line, archs )
+
+ dest = ""
+ for ( inx in archs ) {
+ split( archs[inx], opt, "=" );
+ if ( opt[1] == "all" )
+ dest = opt[2]
+
+ if ( opt[1] == arch ) {
+ dest = opt[2]
+ break
+ }
+ }
+ if ( length( dest ) ) {
+ option = "CONFIG_" option
+
+ if ( dest == "n" )
+ out = "# " option " is not set"
+ else
+ out = option "=" dest
+ print out
+
+ outputArray[ option ] = FILENAME " (" FNR ")"
+ }
+}
+
+END {
+}
================================================================
More information about the pld-cvs-commit
mailing list