script to generate kernel configuration file
am 10.09.2007 22:38:46 von onkar
I have 2 files :
FILE1
--------------------
CONFIG_X86_32=y
CONFIG_GENERIC_TIME=y
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_SEMAPHORE_SLEEPERS=y
CONFIG_X86=y
CONFIG_MMU=y
CONFIG_GENERIC_ISA_DMA=y
CONFIG_GENERIC_IOMAP=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_ARCH_MAY_HAVE_PC_FDC=y
CONFIG_DMI=y
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
::::::::::::::::::
::::::::::::::::::
::::::::::::::::::
many lines like this
::::::::::::::::::
::::::::::::::::::
FILE2
---------------------------
CONFIG_X86_32=y
CONFIG_GENERIC_TIME=y
CONFIG_LOCKDEP_SUPPORT=y
CONFIG_STACKTRACE_SUPPORT=y
CONFIG_SEMAPHORE_SLEEPERS=y
CONFIG_X86=y
CONFIG_MMU=y
CONFIG_GENERIC_ISA_DMA=y
CONFIG_GENERIC_IOMAP=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_ARCH_MAY_HAVE_PC_FDC=y
CONFIG_DMI=y
CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
::::::::::::::::::
::::::::::::::::::
::::::::::::::::::
many lines like this
::::::::::::::::::
::::::::::::::::::
I want to generate a file FILE3 wherein the contents of FILE1 are
retained
for instance
if FILE1 contains
CONFIG_X86_32=n
and FILE2 contains
CONFIG_X86_32=y
then FILE3 (newly generated file) must contain
CONFIG_X86_32=n
all other contents in FILE2 (that are not present in FILE1) should be
copied to FILE3 verbatim.
Thanks,
Onkar
Re: script to generate kernel configuration file
am 11.09.2007 00:12:56 von Kenan Kalajdzic
onkar wrote:
> I have 2 files :
>
>
> FILE1
>
> --------------------
> CONFIG_X86_32=y
> CONFIG_GENERIC_TIME=y
> CONFIG_LOCKDEP_SUPPORT=y
> CONFIG_STACKTRACE_SUPPORT=y
> CONFIG_SEMAPHORE_SLEEPERS=y
> CONFIG_X86=y
> CONFIG_MMU=y
> CONFIG_GENERIC_ISA_DMA=y
> CONFIG_GENERIC_IOMAP=y
> CONFIG_GENERIC_HWEIGHT=y
> CONFIG_ARCH_MAY_HAVE_PC_FDC=y
> CONFIG_DMI=y
> CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
> ::::::::::::::::::
> ::::::::::::::::::
> ::::::::::::::::::
> many lines like this
> ::::::::::::::::::
> ::::::::::::::::::
>
>
> FILE2
>
> ---------------------------
>
> CONFIG_X86_32=y
> CONFIG_GENERIC_TIME=y
> CONFIG_LOCKDEP_SUPPORT=y
> CONFIG_STACKTRACE_SUPPORT=y
> CONFIG_SEMAPHORE_SLEEPERS=y
> CONFIG_X86=y
> CONFIG_MMU=y
> CONFIG_GENERIC_ISA_DMA=y
> CONFIG_GENERIC_IOMAP=y
> CONFIG_GENERIC_HWEIGHT=y
> CONFIG_ARCH_MAY_HAVE_PC_FDC=y
> CONFIG_DMI=y
> CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
> ::::::::::::::::::
> ::::::::::::::::::
> ::::::::::::::::::
> many lines like this
> ::::::::::::::::::
> ::::::::::::::::::
>
>
> I want to generate a file FILE3 wherein the contents of FILE1 are
> retained
> for instance
>
> if FILE1 contains
> CONFIG_X86_32=n
>
> and FILE2 contains
> CONFIG_X86_32=y
>
> then FILE3 (newly generated file) must contain
> CONFIG_X86_32=n
>
> all other contents in FILE2 (that are not present in FILE1) should be
> copied to FILE3 verbatim.
Here is a simple solution that should do it:
awk -F= '
/^CONFIG/ {
if ( conf[$1] == "" )
conf[$1] = $2
}
END {
for ( i in conf )
print i "=" conf[i]
}
' FILE1 FILE2 >FILE3
--
Kenan Kalajdzic