[coreboot-gerrit] New patch to review for coreboot: 0e9466c Add miniconfig, a script to minimize coreboot configurations

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Tue Mar 24 21:56:26 CET 2015


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/8974

-gerrit

commit 0e9466cc0de13eb7075fb21a0ad15ab48d651896
Author: Stefan Reinauer <stefan.reinauer at coreboot.org>
Date:   Tue Mar 24 21:46:52 2015 +0100

    Add miniconfig, a script to minimize coreboot configurations
    
    This script produces a "minimal" configuration from a full coreboot
    configuration, e.g. a configuration file that only contains the differences
    between the default configuration of a board and the input configuration
    file.
    
    Usage: util/miniconfig/miniconfig config.big config.mini
    
    This will read config.big and produce config.mini. If you omit config.mini,
    config.big will be changed in place.
    
    Change-Id: Ifbee49e0192c2c557b18bcc1a92fe2a5d5164a3a
    Signed-off-by: Stefan Reinauer <stefan.reinauer at coreboot.org>
---
 util/miniconfig/miniconfig | 85 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/util/miniconfig/miniconfig b/util/miniconfig/miniconfig
new file mode 100755
index 0000000..e88a54f
--- /dev/null
+++ b/util/miniconfig/miniconfig
@@ -0,0 +1,85 @@
+#!/bin/bash
+#
+# miniconfig - utility to minimize your coreboot config files
+#
+# Copyright 2015 Google Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+
+CONFIG=$1
+NEWCONFIG=$2
+
+CONF=build/util/kconfig/conf
+KCONFIG=src/Kconfig
+DOTCONFIG=.config
+PREVCONFIG=.config.prev
+TMPCONFIG=.config.mini
+
+recreate_config()
+{
+	$CONF --olddefconfig $KCONFIG &> /dev/null
+}
+
+if [ "$CONFIG" == "" ]; then
+  printf "usage: util/miniconfig/miniconfig [path to config file] <path to new config file>\n"
+  exit 0
+fi
+
+if [ ! -r $CONFIG ]; then
+  printf "Can't read $CONFIG.\n"
+  exit 1
+fi
+
+
+if [ $CONFIG == .config ]; then
+  printf "Can't use .config, it's overwritten. Make a backup.\n"
+  exit 1
+fi
+
+if [ ! -x $CONF ]; then
+  printf "conf utility at $CONF not available.\n"
+  exit 1
+fi
+
+VENDOR=$( grep ^CONFIG_VENDOR $CONFIG | cut -f1 -d= )
+BOARD=$( grep ^CONFIG_BOARD $CONFIG | grep -v ROMSIZE | grep -v SPECIFIC_OPTIONS | cut -f1 -d= )
+
+printf "$VENDOR=y\n$BOARD=y\n" > $TMPCONFIG
+
+cp $TMPCONFIG $DOTCONFIG
+recreate_config
+
+LINES=$( cat $CONFIG | wc -l )
+CUR=1
+
+cat $CONFIG | while read L; do
+  printf "\rProcessing $CONFIG - $CUR / $LINES (%d%%)" $(( $CUR * 100 / $LINES))
+  mv $DOTCONFIG $PREVCONFIG
+  cp $TMPCONFIG $DOTCONFIG
+  echo "$L" >> $DOTCONFIG
+  recreate_config
+
+  if ! diff -q $DOTCONFIG $PREVCONFIG > /dev/null; then
+    echo "$L" >> $TMPCONFIG
+  fi
+  CUR=$(( $CUR + 1 ))
+done
+
+echo
+
+if [ "$NEWCONFIG" != "" ]; then
+  printf "Writing new, minimized config to $NEWCONFIG\n"
+  mv $TMPCONFIG $NEWCONFIG
+else
+  printf "Overwriting $CONFIG with new, minimized config.\n"
+  mv $TMPCONFIG $CONFIG
+fi
+



More information about the coreboot-gerrit mailing list