Add task to create kernel config fragments
cover Add task to create kernel config fragments
Hi,
These patches add a new task called fragmentconfig which should be used when the user need to extract a diff between two kernel config files.
For instance:
bitbake -c menuconfig linux-yoco
[do some changes and save]
bitbake -c fragmentconfig linux-yocto
See the fragment.cfg in $WORKDIR/fragment.cfg
This closes [YOCTO #3862]
Thanks.
João Henrique Ferreira de Freitas (2):
kernel-yocto: Add do_fragmentconfig task
cml1.bbclass: Add fragmentconfig task to cml1
meta/classes/cml1.bbclass | 35 +++++++++++++++++++++++++++++++++++ meta/classes/kernel-yocto.bbclass | 2 ++ 2 files changed, 37 insertions(+)
Signature · 1 line
1.8.3.2
PATCH 1/2 kernel-yocto: Add do_fragmentconfig task
Instead of using 'diff' command between two kernel config files, the task fragmentconfig does the job creating the file $WORKDIR/fragment.cfg that user should review and use.
[YOCTO #3862]
--- meta/classes/kernel-yocto.bbclass | 2 ++ 1 file changed, 2 insertions(+)
meta/classes/kernel-yocto.bbclass +2 -0
@@ -411,3 +411,5 @@ do_kernel_link_vmlinux() { OE_TERMINAL_EXPORTS += "GUILT_BASE KBUILD_OUTPUT" GUILT_BASE = "meta" KBUILD_OUTPUT = "${B}" + +do_fragmentconfig[depends] += "virtual/kernel:do_kernel_configme"
Signature · 1 line
1.8.3.2
PATCH 2/2 cml1.bbclass: Add fragmentconfig task to cml1
In reply to João Henrique Ferreira de Freitasfragmentconfig() is a new task that makes a diff between the old and new config files and writes to the fragment.cfg result file. menuconfig() always copy the original config file, so the user doesn't need to copy it.
--- meta/classes/cml1.bbclass | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
meta/classes/cml1.bbclass +35 -0
@@ -16,8 +16,12 @@ HOST_LOADLIBES = "-lncurses" TERMINFO = "${STAGING_DATADIR_NATIVE}/terminfo" python do_menuconfig() { + import os + import shutil + try: mtime = os.path.getmtime(".config") + shutil.copy(".config", ".config.orig") except OSError: mtime = 0
@@ -38,3 +42,34 @@ do_menuconfig[depends] += "ncurses-native:do_populate_sysroot" do_menuconfig[nostamp] = "1" addtask menuconfig after do_configure +python do_fragmentconfig() { + import shutil + import subprocess + + workdir = d.getVar('WORKDIR', True) + fragment = workdir + '/fragment.cfg' + configorig = '.config.orig' + config = '.config' + + try: + md5newconfig = bb.utils.md5_file(configorig) + md5config = bb.utils.md5_file(config) + isdiff = md5newconfig != md5config + except OSError: + isdiff = 0 + + if isdiff: + bb.note("Dumping config fragment into: '%s'." % fragment) + bb.note("new '%s' old '%s'" % (md5newconfig,md5config)) + + statement = 'diff -Nurp ' + configorig + ' ' + config + '| sed -n "s/^\+//p" >' + fragment + subprocess.call(statement, shell=True) + + shutil.copy(configorig, config) + else: + if os.path.exists(fragment): + os.unlink(fragment) +} + +do_fragmentconfig[nostamp] = "1" +addtask fragmentconfig
Signature · 1 line
1.8.3.2
Re: [PATCH 2/2] cml1.bbclass: Add fragmentconfig task to cml1
Quoted 4 lines · João Henrique Ferreira de Freitas
fragmentconfig()is a new task that makes a diff between the old and new config files and writes to the fragment.cfg result file.menuconfig()always copy the original config file, so the user doesn't need to copy it.
Hi João,
Generally looks pretty good. Some comments below, mostly about usability and robustness.
I do have reservations about the task name, partly because it's long and hard to type.... I'm not coming up with something I like a lot better though.... Maybe....
$ bitbake linux-yocto -c diffcfg
Or
$ bitbake linux-yocto -c diffconfig
I like the latter because it is consistent in naming, <action>config, with menuconfig.
Quoted 32 lines
Signed-off-by João Henrique Ferreira de Freitas <[email protected]>---
meta/classes/cml1.bbclass | 35 +++++++++++++++++++++++++++++++++++1 file changed, 35 insertions(+)meta/classes/cml1.bbclass +0
-0@@ -16,8 +16,12 @@ HOST_LOADLIBES = "-lncurses"TERMINFO = "${STAGING_DATADIR_NATIVE}/terminfo"
python
do_menuconfig(){meta/classes/cml1.bbclass +4
-0+ import os + import shutil + try: mtime = os.path.getmtime(".config") + shutil.copy(".config", ".config.orig") except OSError: mtime = 0@@ -38,3 +42,34 @@ do_menuconfig[depends] +="ncurses-native:do_populate_sysroot"
do_menuconfig[nostamp] = "1"
addtask menuconfig afterdo_configuremeta/classes/cml1.bbclass +4
-0+python do_fragmentconfig() { + import shutil + import subprocess +
meta/classes/cml1.bbclass do_menuconfig[depends] += "ncurses-native:do_populate_sysroot" · line 58
Quoted 10 lines
meta/classes/cml1.bbclass +10
-0+ workdir = d.getVar('WORKDIR', True) + fragment = workdir + '/fragment.cfg' + configorig = '.config.orig' + config = '.config' + + try: + md5newconfig = bb.utils.md5_file(configorig) + md5config = bb.utils.md5_file(config) + isdiff = md5newconfig != md5config + except OSError:
We should be doing something to indicate failure here.
meta/classes/cml1.bbclass do_menuconfig[depends] += "ncurses-native:do_populate_sysroot" · line 63
Quoted 5 lines
meta/classes/cml1.bbclass +5
-0+ isdiff = 0 + + if isdiff: + bb.note("Dumping config fragment into: '%s'." % fragment) + bb.note("new '%s' old '%s'" % (md5newconfig,md5config))
Nit, add space after ","
meta/classes/cml1.bbclass do_menuconfig[depends] += "ncurses-native:do_populate_sysroot" · line 68
Quoted 6 lines
meta/classes/cml1.bbclass +5
-1+ + statement = 'diff -Nurp ' + configorig + ' ' + config + '| sed -n "s/^\+//p" >' + fragment + subprocess.call(statement, shell=True) + + shutil.copy(configorig, config)
We should be printing something to make it easy for the user to find the fragment.
Quoted 11 lines
meta/classes/cml1.bbclass +7
-0+ else: + if os.path.exists(fragment): + os.unlink(fragment) +} + +do_fragmentconfig[nostamp] = "1" +addtask fragmentconfigSignature · 1 line
1.8.3.2
Signature · 3 lines
Darren Hart Yocto Project - Linux Kernel Intel Open Source Technology Center
Re: [PATCH 2/2] cml1.bbclass: Add fragmentconfig task to cml1
Hi Darren,
Quoted 5 lines
$ bitbake linux-yocto -c diffconfigI like the latter because it is consistent in naming, <action>config, with menuconfig.
Ok.
Quoted 7 lines
meta/classes/cml1.bbclass do_menuconfig[depends] += "ncurses-native:do_populate_sysroot" · line 58
Quoted 5 lines
meta/classes/cml1.bbclass +5
-0+ try: + md5newconfig = bb.utils.md5_file(configorig) + md5config = bb.utils.md5_file(config) + isdiff = md5newconfig != md5config + except OSError:We should be doing something to indicate failure here.
Ok.
Quoted 10 lines
meta/classes/cml1.bbclass do_menuconfig[depends] += "ncurses-native:do_populate_sysroot" · line 68
Quoted 7 lines
(quoted diff) +2
-0+ + statement = 'diff -Nurp ' + configorig + ' ' + config + '|sed -n "s/^\+//p" >' + fragment
meta/classes/cml1.bbclass +3
-0+ subprocess.call(statement, shell=True) + + shutil.copy(configorig, config)We should be printing something to make it easy for the user to find the fragment.
I've suppose that the bb.note did it. But the messages doesn't appear on console. Only in the log.do_diffconfig log file.
What is the trick here? Should I use bb.warn() or logger.info() ?
Thanks.
Signature · 2 lines
João Henrique Ferreira de Freitas - joaohf_at_gmail.com Campinas-SP-Brasil
Re: [PATCH 2/2] cml1.bbclass: Add fragmentconfig task to cml1
In reply to João Henrique Ferreira de FreitasQuoted 15 lines · João Henrique Ferreira de Freitas
fragmentconfig()is a new task that makes a diff between the old and new config files and writes to the fragment.cfg result file.menuconfig()always copy the original config file, so the user doesn't need to copy it.Signed-off-by João Henrique Ferreira de Freitas <[email protected]>--- meta/classes/cml1.bbclass | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)meta/classes/cml1.bbclass +0
-0
meta/classes/cml1.bbclass HOST_LOADLIBES = "-lncurses" · line 19
Quoted 4 lines
meta/classes/cml1.bbclass +1
-0@@ -16,8 +16,12 @@ HOST_LOADLIBES = "-lncurses" TERMINFO = "${STAGING_DATADIR_NATIVE}/terminfo" python do_menuconfig() { + import os
Don't import os please, this is always present so we don't need to.
Quoted 43 lines
meta/classes/cml1.bbclass +34
-0+ import shutil + try: mtime = os.path.getmtime(".config") + shutil.copy(".config", ".config.orig") except OSError: mtime = 0@@ -38,3 +42,34 @@ do_menuconfig[depends] += "ncurses-native:do_populate_sysroot" do_menuconfig[nostamp] = "1" addtask menuconfig after do_configure +python do_fragmentconfig() { + import shutil + import subprocess + + workdir = d.getVar('WORKDIR', True) + fragment = workdir + '/fragment.cfg' + configorig = '.config.orig' + config = '.config' + + try: + md5newconfig = bb.utils.md5_file(configorig) + md5config = bb.utils.md5_file(config) + isdiff = md5newconfig != md5config + except OSError: + isdiff = 0 + + if isdiff: + bb.note("Dumping config fragment into: '%s'." % fragment) + bb.note("new '%s' old '%s'" % (md5newconfig,md5config)) + + statement = 'diff -Nurp ' + configorig + ' ' + config + '| sed -n "s/^\+//p" >' + fragment + subprocess.call(statement, shell=True) + + shutil.copy(configorig, config) + else: + if os.path.exists(fragment): + os.unlink(fragment) +} + +do_fragmentconfig[nostamp] = "1" +addtask fragmentconfig
Re: [PATCH 2/2] cml1.bbclass: Add fragmentconfig task to cml1
Quoted 12 lines · Richard Purdie
Quoted 10 lines · João Henrique Ferreira de Freitas
fragmentconfig()is a new task that makes a diff between the old and new config files and writes to the fragment.cfg result file.menuconfig()always copy the original config file, so the user doesn't need to copy it.Signed-off-by João Henrique Ferreira de Freitas <[email protected]>--- meta/classes/cml1.bbclass | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
Quoted 4 lines
meta/classes/cml1.bbclass
Quoted 4 lines
meta/classes/cml1.bbclass +0
-0
One more thought on this. As this is currently linux-yocto specific, does it belong in cml1.bbclass? It may make sense in busybox as well, so maybe this is the right place.
RP, do you have a preference?
Signature · 3 lines
Darren Hart Yocto Project - Linux Kernel Intel Open Source Technology Center
Re: [PATCH 2/2] cml1.bbclass: Add fragmentconfig task to cml1
Quoted 24 lines · Darren Hart
Quoted 12 lines · Richard Purdie
Quoted 10 lines · João Henrique Ferreira de Freitas
fragmentconfig()is a new task that makes a diff between the old and new config files and writes to the fragment.cfg result file.menuconfig()always copy the original config file, so the user doesn't need to copy it.Signed-off-by João Henrique Ferreira de Freitas <[email protected]>--- meta/classes/cml1.bbclass | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)Quoted 4 lines
meta/classes/cml1.bbclass
Quoted 4 lines
meta/classes/cml1.bbclass +0
-0One more thought on this. As this is currently linux-yocto specific, does it belong in cml1.bbclass? It may make sense in busybox as well, so maybe this is the right place.
Quoted 1 line
RP, do you have a preference?
Its starting to head in a direction we could probably use a kern-tools.bbclass to keep the code in a common place.
Cheers,
Richard
Re: [PATCH 2/2] cml1.bbclass: Add fragmentconfig task to cml1
Quoted 27 lines · Richard Purdie
Quoted 26 lines · Darren Hart
Quoted 12 lines · Richard Purdie
Quoted 10 lines · João Henrique Ferreira de Freitas
fragmentconfig()is a new task that makes a diff between the old and new config files and writes to the fragment.cfg result file.menuconfig()always copy the original config file, so the user doesn't need to copy it.Signed-off-by João Henrique Ferreira de Freitas <[email protected]>--- meta/classes/cml1.bbclass | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)Quoted 4 lines
meta/classes/cml1.bbclass
Quoted 4 lines
meta/classes/cml1.bbclass +0
-0One more thought on this. As this is currently linux-yocto specific, does
it belong in cml1.bbclass? It may make sense in busybox as well, so maybe
this is the right place.
Quoted 4 lines
Quoted 1 line
RP, do you have a preference?
Its starting to head in a direction we could probably use a kern-tools.bbclass to keep the code in a common place.
I wonder if something like kconfig.bbclass, rather than tying it to the linux-yocto tooling (as it doesn't use any of the tooling to create the fragment). Busybox could then use this, for example (not that it couldn't include kern-tools.bbclass, it just seems a bit less natural to do so).
Signature · 3 lines
Darren Hart Yocto Project - Linux Kernel Intel Open Source Technology Center
Re: [PATCH 2/2] cml1.bbclass: Add fragmentconfig task to cml1
Quoted 32 lines · Darren Hart
Quoted 29 lines · Richard Purdie
Quoted 27 lines · Darren Hart
Quoted 12 lines · Richard Purdie
Quoted 10 lines · João Henrique Ferreira de Freitas
fragmentconfig()is a new task that makes a diff between the old and new config files and writes to the fragment.cfg result file.menuconfig()always copy the original config file, so the user doesn't need to copy it.Signed-off-by João Henrique Ferreira de Freitas <[email protected]>--- meta/classes/cml1.bbclass | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)Quoted 4 lines
meta/classes/cml1.bbclass
Quoted 4 lines
meta/classes/cml1.bbclass +0
-0One more thought on this. As this is currently linux-yocto specific, does
it belong in cml1.bbclass? It may make sense in busybox as well, so maybe
this is the right place.RP, do you have a preference?
Quoted 7 lines
Quoted 2 lines
Its starting to head in a direction we could probably use a kern-tools.bbclass to keep the code in a common place.
I wonder if something like kconfig.bbclass, rather than tying it to the linux-yocto tooling (as it doesn't use any of the tooling to create the fragment). Busybox could then use this, for example (not that it couldn't include kern-tools.bbclass, it just seems a bit less natural to do so).
Well, busybox does DEPEND on the kern-tools-native package. cml1.bbclass is effectively a kconfig.bbclass. I'd be ok with this code there, the fragment is kern-tools specific at this point but its not a big deal...
Cheers,
Richard