Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Alexey Romanov <avromanov@sberdevices.ru>
Cc: patrickdepinguin@gmail.com, kernel@sberdevices.ru,
	Dmitry Rokosov <ddrokosov@sberdevices.ru>,
	thomas.petazzoni@bootlin.com, buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH v1] pkg-config.mk: introduce savefragment subcommand
Date: Sat, 19 Aug 2023 15:42:38 +0200	[thread overview]
Message-ID: <20230819134039.GA1777680@scaer> (raw)
In-Reply-To: <20230818101754.73199-1-avromanov@sberdevices.ru>

Alexey, All,

On 2023-08-18 13:17 +0300, Alexey Romanov via buildroot spake thusly:
> Useful subcommand designed for run savedefconfig with fragment files.
> Simple example of usage:
> 
> m linux-savefragment fragment=radio1_a_debug.fragment

Generating a new fragment is not usually that useful; indeed, whether a
configuration item changed (enabled, disabled, set to something) is
important, and only a human can decide what part of the configuration
files such change in setting should go: main configuration file, or one
of the following fragments.

To help achioeve this, there is already a command to generate a diff of
the current configuration against the "configured-known" one:

    $ make linux-diff-config

Then the user can decide to update the existing main configuration file,
update an existing fragment, or create a new fragment.

This is however not documented, and if we need something, it is
documentation for that existing command rather than a new one;
see lines 100-onward.

Can you look into that instead, please?

Regards,
Yann E. MORIN.

> The saved fragment for such fragment will be in:
> 
> out/$(target)/build/linux-custom/arch/$(arch)/configs/$(target).fragment
> 
> Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru>
> Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>
> ---
>  package/pkg-kconfig.mk | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> diff --git a/package/pkg-kconfig.mk b/package/pkg-kconfig.mk
> index 32dcfea0bc..7e5c7d88a1 100644
> --- a/package/pkg-kconfig.mk
> +++ b/package/pkg-kconfig.mk
> @@ -37,6 +37,40 @@ define kconfig-package-savedefconfig
>  		$(PKG_KCONFIG_COMMON_OPTS) $($(1)_KCONFIG_OPTS) savedefconfig
>  endef
>  
> +FRAGMENT_CONFIG_PATH=arch/$(KERNEL_ARCH)/configs
> +
> +# Macro to save the fragment file
> +# $(1): the name of the package in upper-case letters
> +# $(2): the fragment name
> +define kconfig-package-savefragment
> +	$(eval ORIG_CONFIG=$(shell mktemp))
> +	$(eval CHANGED_CONFIG=$(shell mktemp))
> +	$(eval DIFF_CONFIG=$(shell mktemp))
> +	$(eval NEW_FRAGMENT=$(shell mktemp))
> +
> +	$(Q) cp $($(1)_DIR)/.config $(CHANGED_CONFIG)
> +
> +	$($(1)_MAKE_ENV) $($(1)_MAKE) -C $($(1)_DIR) \
> +		$(PKG_KCONFIG_COMMON_OPTS) $($(1)_KCONFIG_OPTS) \
> +		$($(1)_KCONFIG_DEFCONFIG)
> +
> +	$(Q) cp $($(1)_DIR)/.config $(ORIG_CONFIG)
> +
> +	$(Q) $($(1)_DIR)/scripts/diffconfig -m $(ORIG_CONFIG) \
> +		$(CHANGED_CONFIG) > $(DIFF_CONFIG)
> +	$(Q) KCONFIG_CONFIG=$(NEW_FRAGMENT) \
> +		$($(1)_DIR)/scripts/kconfig/merge_config.sh \
> +		-m $($(1)_DIR)/$(FRAGMENT_CONFIG_PATH)/$(2) $(DIFF_CONFIG)
> +	$(Q) sed -E -e 's/.*(CONFIG_[^ =]+).*/\1 \0/' $(NEW_FRAGMENT) \
> +		| sort -k1 |  cut -d " " -f 2- > \
> +		$($(1)_DIR)/$(FRAGMENT_CONFIG_PATH)/$(2)
> +
> +	$(Q) cp $(CHANGED_CONFIG) $($(1)_DIR)/.config
> +
> +	$(Q) rm -f $(ORIG_CONFIG) $(CHANGED_CONFIG) \
> +		$(DIFF_CONFIG) $(NEW_FRAGMENT)
> +endef
> +
>  # The correct way to regenerate a .config file is to use 'make olddefconfig'.
>  # For historical reasons, the target name is 'oldnoconfig' between Linux kernel
>  # versions 2.6.36 and 3.6, and remains as an alias in later versions.
> @@ -282,6 +316,12 @@ $(1)-savedefconfig: $(1)-check-configuration-done
>  	$$(call kconfig-package-savedefconfig,$(2))
>  endif
>  
> +ifeq ($$($(2)_KCONFIG_SUPPORTS_DEFCONFIG),YES)
> +.PHONY: $(1)-savefragment
> +$(1)-savefragment: $(1)-check-configuration-done
> +	$$(call kconfig-package-savefragment,$(2),$(fragment))
> +endif
> +
>  ifeq ($$($(2)_KCONFIG_DEFCONFIG),)
>  # Target to copy back the configuration to the source configuration file
>  # Even though we could use 'cp --preserve-timestamps' here, the separate
> -- 
> 2.30.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

      reply	other threads:[~2023-08-19 13:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18 10:17 [Buildroot] [PATCH v1] pkg-config.mk: introduce savefragment subcommand Alexey Romanov via buildroot
2023-08-19 13:42 ` Yann E. MORIN [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230819134039.GA1777680@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=avromanov@sberdevices.ru \
    --cc=buildroot@buildroot.org \
    --cc=ddrokosov@sberdevices.ru \
    --cc=kernel@sberdevices.ru \
    --cc=patrickdepinguin@gmail.com \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox