[7/7] kconfig: search for a config to base the local(mod|yes)config on
diff mbox

Message ID 20090430185223.792841532@goodmis.org
State New, archived
Headers show

Commit Message

Steven Rostedt April 30, 2009, 6:50 p.m. UTC
From: Steven Rostedt <srostedt@redhat.com>

Instead of using the .config in the local directory. This patch
changes streamline_config.pl to search various locations for a config.

Here's the list and order of search:

  /proc/config.gz
  /boot/vmlinuz-`uname -r`
  vmlinux  # local to the directory
  /lib/modules/`uname -r`/kernel/kernel/configs.ko
  kernel/configs.ko
  kernel/configs.o
  .config

Once it finds a file that contains a config (it checks if the binary
objects have configs first) it then uses it to create the .config
with minimum modules needed.

[ Impact: use mostly the current config ]

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 scripts/kconfig/streamline_config.pl |   63 +++++++++++++++++++++++++++++++++-
 1 files changed, 62 insertions(+), 1 deletions(-)

Comments

Alan Jenkins April 30, 2009, 10:04 p.m. UTC | #1
On 4/30/09, Steven Rostedt <rostedt@goodmis.org> wrote:
> From: Steven Rostedt <srostedt@redhat.com>
>
> Instead of using the .config in the local directory. This patch
> changes streamline_config.pl to search various locations for a config.
>
> Here's the list and order of search:
>
>   /proc/config.gz
>   /boot/vmlinuz-`uname -r`
>   vmlinux  # local to the directory
>   /lib/modules/`uname -r`/kernel/kernel/configs.ko
>   kernel/configs.ko
>   kernel/configs.o
>   .config
>
> Once it finds a file that contains a config (it checks if the binary
> objects have configs first) it then uses it to create the .config
> with minimum modules needed.

Maybe this has already been discussed, but is there some reason for
omitting /boot/config-`uname -r`?  My understanding as a user of a
specific distribution was that kernel packages provide these files,
and therefore do not feel the need to enable CONFIG_IKCONFIG.

Regards
Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Steven Rostedt April 30, 2009, 10:54 p.m. UTC | #2
On Thu, 30 Apr 2009, Alan Jenkins wrote:

> On 4/30/09, Steven Rostedt <rostedt@goodmis.org> wrote:
> > From: Steven Rostedt <srostedt@redhat.com>
> >
> > Instead of using the .config in the local directory. This patch
> > changes streamline_config.pl to search various locations for a config.
> >
> > Here's the list and order of search:
> >
> >   /proc/config.gz
> >   /boot/vmlinuz-`uname -r`
> >   vmlinux  # local to the directory
> >   /lib/modules/`uname -r`/kernel/kernel/configs.ko
> >   kernel/configs.ko
> >   kernel/configs.o
> >   .config
> >
> > Once it finds a file that contains a config (it checks if the binary
> > objects have configs first) it then uses it to create the .config
> > with minimum modules needed.
> 
> Maybe this has already been discussed, but is there some reason for
> omitting /boot/config-`uname -r`?  My understanding as a user of a
> specific distribution was that kernel packages provide these files,
> and therefore do not feel the need to enable CONFIG_IKCONFIG.

You know, I did not even think about that :-/

I'll update that.

Thanks,

-- Steve

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andi Kleen May 4, 2009, 12:15 p.m. UTC | #3
Steven Rostedt <rostedt@goodmis.org> writes:

> Here's the list and order of search:
>
>   /proc/config.gz
>   /boot/vmlinuz-`uname -r`
>   vmlinux  # local to the directory
>   /lib/modules/`uname -r`/kernel/kernel/configs.ko
>   kernel/configs.ko
>   kernel/configs.o
>   .config


That seems like the wrong order. ./.config should always be first for
compatibility. 

That order would completely wreck all my build scripts, and I suspect
others too.

-Andi
Peter Zijlstra May 4, 2009, 12:28 p.m. UTC | #4
On Mon, 2009-05-04 at 14:15 +0200, Andi Kleen wrote:
> Steven Rostedt <rostedt@goodmis.org> writes:
> 
> > Here's the list and order of search:
> >
> >   /proc/config.gz
> >   /boot/vmlinuz-`uname -r`
> >   vmlinux  # local to the directory
> >   /lib/modules/`uname -r`/kernel/kernel/configs.ko
> >   kernel/configs.ko
> >   kernel/configs.o
> >   .config
> 
> 
> That seems like the wrong order. ./.config should always be first for
> compatibility. 
> 
> That order would completely wreck all my build scripts, and I suspect
> others too.

Quite, except that I hardly ever have a ./.config since I make extensive
use of O=foo
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Steven Rostedt May 4, 2009, 2:46 p.m. UTC | #5
On Mon, 4 May 2009, Peter Zijlstra wrote:

> On Mon, 2009-05-04 at 14:15 +0200, Andi Kleen wrote:
> > Steven Rostedt <rostedt@goodmis.org> writes:
> > 
> > > Here's the list and order of search:
> > >
> > >   /proc/config.gz
> > >   /boot/vmlinuz-`uname -r`
> > >   vmlinux  # local to the directory
> > >   /lib/modules/`uname -r`/kernel/kernel/configs.ko
> > >   kernel/configs.ko
> > >   kernel/configs.o
> > >   .config
> > 
> > 
> > That seems like the wrong order. ./.config should always be first for
> > compatibility. 
> > 
> > That order would completely wreck all my build scripts, and I suspect
> > others too.
> 
> Quite, except that I hardly ever have a ./.config since I make extensive
> use of O=foo

I'm fine with using .config as first choice (that is what the script 
originally did) but I wanted to make it as easy for non developers as 
possible. Taking from /proc or /boot was most likely the best to give a 
minimal boot environment.

But I can see why .config is probably the best choice for having the most 
power with the tool. It is how you can always force it to do something you 
want, and is the most logical place to expect the script to read from.

I'll update it.

Thanks,

-- Steve

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andi Kleen May 4, 2009, 2:59 p.m. UTC | #6
On Mon, May 04, 2009 at 02:28:06PM +0200, Peter Zijlstra wrote:
> On Mon, 2009-05-04 at 14:15 +0200, Andi Kleen wrote:
> > Steven Rostedt <rostedt@goodmis.org> writes:
> > 
> > > Here's the list and order of search:
> > >
> > >   /proc/config.gz
> > >   /boot/vmlinuz-`uname -r`
> > >   vmlinux  # local to the directory
> > >   /lib/modules/`uname -r`/kernel/kernel/configs.ko
> > >   kernel/configs.ko
> > >   kernel/configs.o
> > >   .config
> > 
> > 
> > That seems like the wrong order. ./.config should always be first for
> > compatibility. 
> > 
> > That order would completely wreck all my build scripts, and I suspect
> > others too.
> 
> Quite, except that I hardly ever have a ./.config since I make extensive
> use of O=foo

yes I do too.  I meant $O/.config sorry

-Andi

Patch
diff mbox

diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl
index 2334641..9fa3f81 100644
--- a/scripts/kconfig/streamline_config.pl
+++ b/scripts/kconfig/streamline_config.pl
@@ -45,7 +45,68 @@ 
 my $config = ".config";
 my $linuxpath = ".";
 
-open(CIN,$config) || die "Can't open current config file: $config";
+my $uname = `uname -r`;
+chomp $uname;
+
+my @searchconfigs = (
+	{
+	    "file" => "/proc/config.gz",
+	    "exec" => "zcat",
+	},
+	{
+	    "file" => "/boot/vmlinuz-$uname",
+	    "exec" => "scripts/extract-ikconfig",
+	    "test" => "scripts/extract-ikconfig",
+	},
+	{
+	    "file" => "vmlinux",
+	    "exec" => "scripts/extract-ikconfig",
+	    "test" => "scripts/extract-ikconfig",
+	},
+	{
+	    "file" => "/lib/modules/$uname/kernel/kernel/configs.ko",
+	    "exec" => "scripts/extract-ikconfig",
+	    "test" => "scripts/extract-ikconfig",
+	},
+	{
+	    "file" => "kernel/configs.ko",
+	    "exec" => "scripts/extract-ikconfig",
+	    "test" => "scripts/extract-ikconfig",
+	},
+	{
+	    "file" => "kernel/configs.o",
+	    "exec" => "scripts/extract-ikconfig",
+	    "test" => "scripts/extract-ikconfig",
+	},
+	{
+	    "file" => ".config",
+	    "exec" => "cat",
+	},
+);
+
+sub find_config {
+    foreach my $conf (@searchconfigs) {
+	my $file = $conf->{"file"};
+
+	next if ( ! -f "$file");
+
+	if (defined($conf->{"test"})) {
+	    `$conf->{"test"} $conf->{"file"} 2>/dev/null`;
+	    next if ($?);
+	}
+
+	my $exec = $conf->{"exec"};
+
+	print STDERR "using config: '$file'\n";
+
+	open(CIN, "$exec $file |") || die "Failed to run $exec $file";
+	return;
+    }
+    die "No config file found";
+}
+
+find_config;
+
 my @makefiles = `find $linuxpath -name Makefile`;
 my %depends;
 my %selects;