In message: [PATCH] kconfig-diff2frag.py: add
on 15/08/2023 Trevor Woerner wrote:

> Add a python tool to generate a config fragment from a unified diff of two
> kernel configurations. The diff is read from stdin and the fragment is printed
> to stdout.
> 
> Usage:
>       $ diff -u config1 config2 | kconfig-diff2frag.py
> 
> Signed-off-by: Trevor Woerner <[email protected]>

Thanks Trevor!

I've queued this, and will run it through some tests.

Bruce

> ---
>  Makefile                   |  3 ++-
>  tools/kconfig-diff2frag.py | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 33 insertions(+), 1 deletion(-)
>  create mode 100755 tools/kconfig-diff2frag.py
> 
> diff --git a/Makefile b/Makefile
> index 2818ecd2fefc..6d481ed52f04 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -3,7 +3,8 @@ kern_tools_LIST = kgit kgit-meta \
>                 kgit-create-buckets \
>                 get_defconfig scc \
>                 merge_config.sh spp kgit-s2q \
> -               symbol_why.py
> +               symbol_why.py \
> +               kconfig-diff2frag.py
>  
>  cmds := $(wildcard tools/scc-cmds/*)
>  libs := Kconfiglib/kconfiglib.py
> diff --git a/tools/kconfig-diff2frag.py b/tools/kconfig-diff2frag.py
> new file mode 100755
> index 000000000000..2c2b2e37b826
> --- /dev/null
> +++ b/tools/kconfig-diff2frag.py
> @@ -0,0 +1,31 @@
> +#! /usr/bin/env python3
> +#
> +## Copyright (C) 2023  Trevor Woerner <[email protected]>
> +## SPDX-License-Identifier: OSLv3
> +## vim: sw=4 ts=4 sts=4 expandtab
> +
> +# This tool takes a unified diff (diff -u <before> <after>) of two kconfig
> +# files and generates a kconfig fragment from the differences.
> +# It reads the diff on stdin and outputs the fragment on stdout.
> +#
> +# Example usage:
> +#    $ diff -u config-before config-after | ./kconfig-diff2frag.py
> +
> +import sys
> +
> +def main():
> +    for LINE in sys.stdin:
> +        # if a line starts with '+CONFIG_*'
> +        # then output the line without the leading '+'
> +        if LINE.find('+CONFIG_') == 0:
> +            print(LINE[1:],end='')
> +
> +        # if a line starts with '+# CONFIG_* is not set'
> +        # then output the line as: CONFIG_*=n
> +        if LINE.find('+# CONFIG_') == 0:
> +            print(LINE.split()[1].strip(),'=n',sep='')
> +
> +        # ignore any other lines
> +
> +if __name__ == "__main__":
> +    main()
> -- 
> 2.41.0.327.gaa9166bcc0ba
> 
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#12985): 
https://lists.yoctoproject.org/g/linux-yocto/message/12985
Mute This Topic: https://lists.yoctoproject.org/mt/100761334/21656
Group Owner: [email protected]
Unsubscribe: 
https://lists.yoctoproject.org/g/linux-yocto/leave/6687884/21656/624485779/xyzzy
 [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to