save kernel version in .config file
PATCH 1/1 save kernel version in .config file
Is this interesting to anyone besides me?
Save kernel version info when writing .config file.
diffstat:=
scripts/kconfig/confdata.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
scripts/kconfig/confdata.c renamed from scripts/kconfig/confdata.c~config_version +7 -2
@@ -301,14 +301,19 @@ int conf_write(const char *name)if (!out_h)return 1 ; } + sym =sym_lookup ("KERNELRELEASE" ,0 );fprintf (out,"#\n" "# Automatically generated make config: don't edit\n" -"#\n" ); +"# for Linux kernel version: %s\n" +"#\n" , + (char *)sym->curr.val);if (out_h)fprintf (out_h,"/*\n" " * Automatically generated C config: don't edit\n" +" * for Linux kernel version: %s\n" " */\n" -"#define AUTOCONF_INCLUDED\n" ); +"#define AUTOCONF_INCLUDED\n" , + (char *)sym->curr.val);if (!sym_change_count)sym_clear_all_valid ();
Quoted 3 lines · Randy.Dunlap
Is this interesting to anyone besides me? Save kernel version info when writing .config file.
Very good idea Randy ! I've already used some wrong config picked out of 20, and having a simple way to do a quick check is really an enhancement. BTW, does KERNELRELEASE include the build number ? and could we include the config date in the file too ?
Regards,
Willy
Quoted 9 lines · Willy Tarreau
Quoted 3 lines · Randy.Dunlap
Is this interesting to anyone besides me? Save kernel version info when writing .config file.
Very good idea Randy ! I've already used some wrong config picked out of 20, and having a simple way to do a quick check is really an enhancement. BTW, does KERNELRELEASE include the build number ? and could we include the config date in the file too ?
Date seems worthwhile. buildnumber does not make sense since we do not generate a new .config for each build.
Sam
On Fri, 18 Jun 2004 22:56:02 +0200 Sam Ravnborg wrote:
| On Fri, Jun 18, 2004 at 07:34:55AM +0200, Willy Tarreau wrote: | > On Thu, Jun 17, 2004 at 10:06:51PM -0700, Randy.Dunlap wrote: | > > | > > Is this interesting to anyone besides me? | > > Save kernel version info when writing .config file. | > | > Very good idea Randy ! I've already used some wrong config picked out of 20, | > and having a simple way to do a quick check is really an enhancement. BTW, | > does KERNELRELEASE include the build number ? and could we include the | > config date in the file too ? | | Date seems worthwhile. buildnumber does not make sense since we do not | generate a new .config for each build.
OK, I've added date, based on Sam's comments, but someone tell me, when/why does filesystem-timestamp not work for this?
Thanks for the replies.
--
~Randy
Save kernel version info and date when writing .config file.
diffstat:=
scripts/kconfig/confdata.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)
scripts/kconfig/confdata.c renamed from scripts/kconfig/confdata.c~config_version +12 -2
@@ -8,6 +8,7 @@#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <unistd.h> #define LKC_DIRECT_LINK
@@ -268,6 +269,7 @@ int conf_write(const char *name)char dirname[128 ], tmpname[128 ], newname[128 ];int type, l;const char *str; +time_t now; dirname[0 ] =0 ;if (name && name[0 ]) {
@@ -301,14 +303,22 @@ int conf_write(const char *name)if (!out_h)return 1 ; } + sym =sym_lookup ("KERNELRELEASE" ,0 ); +time (&now);fprintf (out,"#\n" "# Automatically generated make config: don't edit\n" -"#\n" ); +"# Linux kernel version: %s\n" +"# %s" +"#\n" , + (char *)sym->curr.val,ctime (&now));if (out_h)fprintf (out_h,"/*\n" " * Automatically generated C config: don't edit\n" +" * Linux kernel version: %s\n" +" * %s" " */\n" -"#define AUTOCONF_INCLUDED\n" ); +"#define AUTOCONF_INCLUDED\n" , + (char *)sym->curr.val,ctime (&now));if (!sym_change_count)sym_clear_all_valid ();
Quoted 16 lines · Randy.Dunlap
On Fri, 18 Jun 2004 22:56:02 +0200 Sam Ravnborg wrote:
| On Fri, Jun 18, 2004 at 07:34:55AM +0200, Willy Tarreau wrote: | > On Thu, Jun 17, 2004 at 10:06:51PM -0700, Randy.Dunlap wrote: | > > | > > Is this interesting to anyone besides me? | > > Save kernel version info when writing .config file. | > | > Very good idea Randy ! I've already used some wrong config picked out of 20, | > and having a simple way to do a quick check is really an enhancement. BTW, | > does KERNELRELEASE include the build number ? and could we include the | > config date in the file too ? | | Date seems worthwhile. buildnumber does not make sense since we do not | generate a new .config for each build.
Quoted 2 lines
OK, I've added date, based on Sam's comments, but someone tell me, when/why does filesystem-timestamp not work for this?
Because date is easier to see in grep.
Sam
Hi,
On Fri, 18 Jun 2004, Randy.Dunlap wrote:
Did you test this with anything else than menuconfig?
Review
Quoted 1 line
(quoted diff) +1
-0+ (char *)sym->curr.val, ctime(&now));
Try to avoid poking around in that structure. First the value needs to be calculated with sym_calc_value() and then it can be accessed with sym_get_string_value().
bye, Roman
On Sat, 19 Jun 2004 00:42:19 +0200 (CEST) Roman Zippel wrote:
| Hi, | | On Fri, 18 Jun 2004, Randy.Dunlap wrote: | | Did you test this with anything else than menuconfig?
Nope...
| > + (char *)sym->curr.val, ctime(&now)); | | Try to avoid poking around in that structure. First the value needs to be | calculated with sym_calc_value() and then it can be accessed with | sym_get_string_value().
Thanks, will use that info.
--
~Randy
Quoted 2 lines · Randy.Dunlap
OK, I've added date, based on Sam's comments, but someone tell me, when/why does filesystem-timestamp not work for this?
Oh, there may be lots of reasons. The first one which comes to my mind is when I archive several config files in a same directory, I rarely think about adding '-a' to cp to preserve the dates. And when you're experimenting with a kernel and you're at the 20th at the end of the day, the date in the config file is often more reliable than yourself to keep track of what you have tried.
Thanks,
Willy
PS: do you think this could be done easily to 2.4 too ?
On Sat, 19 Jun 2004 06:07:17 +0200 Willy Tarreau wrote:
| On Fri, Jun 18, 2004 at 03:05:35PM -0700, Randy.Dunlap wrote: | | > OK, I've added date, based on Sam's comments, but someone tell me, | > when/why does filesystem-timestamp not work for this? | | Oh, there may be lots of reasons. The first one which comes to my mind is | when I archive several config files in a same directory, I rarely think | about adding '-a' to cp to preserve the dates. And when you're experimenting | with a kernel and you're at the 20th at the end of the day, the date in the | config file is often more reliable than yourself to keep track of what you | have tried.
I see.
| Thanks, | Willy | | PS: do you think this could be done easily to 2.4 too ?
It's trivial for 'make menuconfig' (bash scripting) [below]. OTOH, I won't look at the tcl/tk 'xconfig' stuff...
--
~Randy
linux-2.4.26
Save kernel version and config file date in config file.
diffstat:=
scripts/Menuconfig | 5 +++++ 1 files changed, 5 insertions(+)
scripts/Menuconfig renamed from scripts/Menuconfig~config_version +5 -0
@@ -1275,13 +1275,18 @@ save_configuration () { CONFIG=.tmpconfig CONFIG_H=.tmpconfig.h + DATTIM=`date` echo "#" >$CONFIG echo "# Automatically generated by make menuconfig: don't edit" >>$CONFIG + echo "# Linux kernel version: $kernel_version" >>$CONFIG + echo "# $DATTIM" >>$CONFIG echo "#" >>$CONFIG echo "/*" >$CONFIG_H echo " * Automatically generated by make menuconfig: don't edit" >>$CONFIG_H + echo " * Linux kernel version: $kernel_version" >>$CONFIG_H + echo " * $DATTIM" >>$CONFIG_H echo " */" >>$CONFIG_H echo "#define AUTOCONF_INCLUDED" >> $CONFIG_H
Quoted 3 lines · Randy.Dunlap
| PS: do you think this could be done easily to 2.4 too ?
It's trivial for 'make menuconfig' (bash scripting) [below].
Cool, thank you very much Randy.
Quoted 1 line
OTOH, I won't look at the tcl/tk 'xconfig' stuff...
Not my problem either, I haven't used it for 3 or 4 years.
Cheers,
Willy
On Sat, 19 Jun 2004 06:07:17 +0200 Willy Tarreau wrote:
| On Fri, Jun 18, 2004 at 03:05:35PM -0700, Randy.Dunlap wrote: | | > OK, I've added date, based on Sam's comments, but someone tell me, | > when/why does filesystem-timestamp not work for this?
and then Roman made some very good comments about looking up and printing symbol values and testing with xconfig and gconfig. Thanks, Roman.
Having done all of that successfully, here is the updated patch for 2.6.7.
Save kernel version info and date when writing .config file.
diffstat:=
scripts/kconfig/confdata.c | 17 +++++++++++++++-- 1 files changed, 15 insertions(+), 2 deletions(-)
scripts/kconfig/confdata.c renamed from scripts/kconfig/confdata.c~config_version +15 -2
@@ -8,6 +8,7 @@#include <stdio.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <unistd.h> #define LKC_DIRECT_LINK
@@ -268,6 +269,7 @@ int conf_write(const char *name)char dirname[128 ], tmpname[128 ], newname[128 ];int type, l;const char *str; +time_t now; dirname[0 ] =0 ;if (name && name[0 ]) {
@@ -301,14 +303,25 @@ int conf_write(const char *name)if (!out_h)return 1 ; } + sym =sym_lookup ("KERNELRELEASE" ,0 ); +sym_calc_value (sym); +time (&now);fprintf (out,"#\n" "# Automatically generated make config: don't edit\n" -"#\n" ); +"# Linux kernel version: %s\n" +"# %s" +"#\n" , +sym_get_string_value (sym), +ctime (&now));if (out_h)fprintf (out_h,"/*\n" " * Automatically generated C config: don't edit\n" +" * Linux kernel version: %s\n" +" * %s" " */\n" -"#define AUTOCONF_INCLUDED\n" ); +"#define AUTOCONF_INCLUDED\n" , +sym_get_string_value (sym), +ctime (&now));if (!sym_change_count)sym_clear_all_valid ();
Quoted 1 line · Randy.Dunlap
Is this interesting to anyone besides me?
Yes. It will help with the hell of config files I have. Thanks.
Hello,
Quoted 3 lines
Is this interesting to anyone besides me?
Is it also possible to have this version being displayed during a make config/make menuconfig/... so that we know we are reading a config file that may have been generated for another kernel version, and not yet saved ?
You would have, for make menuconfig :
Linux Kernel v2.2.13 Configuration, Configuration file version 2.4.20
....
Regards,
Paul
On Fri, 18 Jun 2004 08:38:58 +0200 Paul Rolland wrote:
| Hello, | | > | > Is this interesting to anyone besides me? | > | Is it also possible to have this version being displayed during | a make config/make menuconfig/... so that we know we are reading a | config file that may have been generated for another kernel version, | and not yet saved ? | | You would have, for make menuconfig : | | Linux Kernel v2.2.13 Configuration, Configuration file version 2.4.20
Sure, it's possible. I just don't want to add the kitchen sink.
IOW, I'm not convinced that it's useful most of the time... only a little bit of the time.
--
~Randy
Quoted 6 lines · Randy.Dunlap
Is this interesting to anyone besides me?
Save kernel version info when writing .config file.
I certainly find that to be a nice and useful enhancement - good idea.
--
Jesper Juhl <[email protected]>