changelog shortlog tags changeset manifest revisions annotate raw

sources/toys/miniconfig.sh

changeset 235: c0d9e91f528b
parent:4d55eff218e9
child:e6a201119439
author: Rob Landley <rob@landley.net>
date: Sun Oct 28 03:19:59 2007 -0500 (14 months ago)
permissions: -rwxr-xr-x
description: Improve error message when $1 not found.
1#!/bin/bash
2
3# miniconfig.sh copyright 2005 by Rob Landley <rob@landley.net>
4# Licensed under the GNU General Public License version 2.
5
6# Run this in the linux kernel build directory with a starting file, and
7# it creates a file called mini.config with all the redundant lines of that
8# .config removed. The starting file must match what the kernel outputs.
9# If it doesn't, then run "make oldconfig" on it to get one that does.
10
11export KCONFIG_NOTIMESTAMP=1
12
13if [ $# -ne 1 ]
14then
15 echo "Usage: miniconfig.sh configfile"
16 exit 1
17fi
18
19if [ ! -f "$1" ]
20then
21 echo "Couldn't find "'"'"$1"'"'
22 exit 1
23fi
24
25if [ "$1" == ".config" ]
26then
27 echo "It overwrites .config, rename it and try again."
28 exit 1
29fi
30
31make allnoconfig KCONFIG_ALLCONFIG="$1" > /dev/null
32if ! cmp .config "$1"
33then
34 echo Sanity test failed, normalizing starting configuration...
35 diff -u "$1" .config
36fi
37cp .config .big.config
38cp .config mini.config
39
40echo "Calculating mini.config..."
41
42LENGTH=`cat $1 | wc -l`
43
44# Loop through all lines in the file
45I=1
46while true
47do
48 if [ $I -gt $LENGTH ]
49 then
50 break
51 fi
52 sed -n "${I}!p" mini.config > .config.test
53 # Do a config with this file
54 make allnoconfig KCONFIG_ALLCONFIG=.config.test > /dev/null
55
56 # Compare. Because we normalized at the start, the files should be identical.
57 if cmp -s .config .big.config
58 then
59 mv .config.test mini.config
60 LENGTH=$[$LENGTH-1]
61 else
62 I=$[$I + 1]
63 fi
64 echo -n -e "\r$[$I-1]/$LENGTH lines $(cat mini.config | wc -c) bytes "
65done
66rm .big.config
67echo