Skip to contentSkip to conversation

Add task to create kernel config fragments

PATCH In review João Henrique Ferreira de Freitas 3 participants 8 messages Feb 16, 2014 – Feb 18, 2014

lore
Share & tools
lore
#0 lore raw

v2 cover Add task to create kernel config fragments

Changes in v2:
- address Darren
- task name, using diffconfig
- except on failure
- space after ','
- printing the path to fragment

- address RP's comments (import os)

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_diffconfig task
cml1.bbclass: Add diffconfig task to cml1

 meta/classes/cml1.bbclass         | 33 +++++++++++++++++++++++++++++++++
 meta/classes/kernel-yocto.bbclass |  2 ++
 2 files changed, 35 insertions(+)
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH v2 1/2 kernel-yocto: Add do_diffconfig task

Instead of using 'diff' command between two kernel config files, the task diffconfig 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
index 8f79932..fab5d4c 100644
@@ -411,3 +411,5 @@ do_kernel_link_vmlinux() {
 OE_TERMINAL_EXPORTS += "GUILT_BASE KBUILD_OUTPUT"
 GUILT_BASE = "meta"
 KBUILD_OUTPUT = "${B}"
+
+do_diffconfig[depends] += "virtual/kernel:do_kernel_configme"
Signature · 1 line
1.8.3.2
Acked-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] kernel-yocto: Add do_diffconfig task

Quoted 7 lines · João Henrique Ferreira de Freitas

Instead of using 'diff' command between two kernel config files, the task diffconfig does the job creating the file $WORKDIR/fragment.cfg that user should review and use.

[YOCTO #3862]

Signature · 3 lines
Darren Hart
Yocto Project - Linux Kernel
Intel Open Source Technology Center
#3 lore raw

PATCH v2 2/2 cml1.bbclass: Add diffconfig task to cml1

In reply to João Henrique Ferreira de Freitas

diffconfig() 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 | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
meta/classes/cml1.bbclass +33 -0
index e292ecb..34c0c4e 100644
@@ -16,8 +16,11 @@ HOST_LOADLIBES = "-lncurses"
 TERMINFO = "${STAGING_DATADIR_NATIVE}/terminfo"
 
 python do_menuconfig() {
+    import shutil
+
     try:
         mtime = os.path.getmtime(".config")
+        shutil.copy(".config", ".config.orig")
     except OSError:
         mtime = 0
 
@@ -38,3 +41,33 @@ do_menuconfig[depends] += "ncurses-native:do_populate_sysroot"
 do_menuconfig[nostamp] = "1"
 addtask menuconfig after do_configure
 
+python do_diffconfig() {
+    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 IOError as e:
+        bb.fatal("No config files found. Did you do menuconfig ?\n%s" % e)
+
+    if isdiff:
+        statement = 'diff -Nurp ' + configorig + ' ' + config + '| sed -n "s/^\+//p" >' + fragment
+        subprocess.call(statement, shell=True)
+
+        shutil.copy(configorig, config)
+
+        bb.plain("Config fragment has been dumped into:\n %s" % fragment)
+    else:
+        if os.path.exists(fragment):
+            os.unlink(fragment)
+}
+
+do_diffconfig[nostamp] = "1"
+addtask diffconfig
Signature · 1 line
1.8.3.2
Acked-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] cml1.bbclass: Add diffconfig task to cml1

Quoted 6 lines · João Henrique Ferreira de Freitas

diffconfig() 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.

Signature · 3 lines
Darren Hart
Yocto Project - Linux Kernel
Intel Open Source Technology Center
#5 lore raw
In reply to João Henrique Ferreira de Freitas

Hello Joao,

Quoted 18 lines · João Henrique Ferreira de Freitas

Changes in v2:
- address Darren
- task name, using diffconfig
- except on failure
- space after ','
- printing the path to fragment

- address RP's comments (import os)

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

Quoted 7 lines

[do some changes and save]

bitbake -c fragmentconfig linux-yocto

See the fragment.cfg in $WORKDIR/fragment.cfg

This closes [YOCTO #3862]

I do like the patchset except that his cover letter seems outdate as the task now is diffconfig. Maybe you could add another task too, which we use quite often in meta-fsl-arm, savedefconfig. This would easy people to generate strimmed versions for use.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#6 lore raw

Hi Otavio,

Quoted 2 lines

I do like the patchset except that his cover letter seems outdate as the task now is diffconfig.

You are right.

Quoted 4 lines

Maybe you could add another task too,
which we use quite often in meta-fsl-arm, savedefconfig. This would easy people to generate strimmed versions for use.

Yes, after this patch is accepted, I will prepare the savedefconfig task (cml1.bbclass).

Thanks.

Quoted 5 lines

--
Otavio Salvador O.S. Systems
http://www.ossystems.com.br http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854 Mobile: +1 (347) 903-9750

Signature · 2 lines
João Henrique Ferreira de Freitas - joaohf_at_gmail.com
Campinas-SP-Brasil
#7 lore raw

Hello Joao,

Quoted 7 lines · João Henrique Freitas
Quoted 2 lines

I do like the patchset except that his cover letter seems outdate as the task now is diffconfig.

You are right.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

Maybe you could add another task too,
which we use quite often in meta-fsl-arm, savedefconfig. This would easy people to generate strimmed versions for use.

Yes, after this patch is accepted, I will prepare the savedefconfig task (cml1.bbclass).

Great; thanks.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750