Skip to contentSkip to conversation

Buildroot: Target to update config fragments in kconfig based packages

PATCH New Marcel Patzlaff 4 participants 17 messages Jul 30, 2018 – Aug 15, 2018

lore
Share & tools
lore
#0 lore raw

cover Buildroot: Target to update config fragments in kconfig based packages

The intention of this patch series is to allow developers to change the configuration via menuconfig or whatever editor and to apply those changes automatically to the last fragment. This should further ease layering of buildroot configurations.

This patch series introduces, besides some refactoring for code sharing, a new make target for kconfig based packages:
<pkg>-update-last-config-fragment

The new target updates the last configuration fragment that is specified in <PKG>_KCONFIG_FRAGMENT_FILES in a defined way. Let's assume that we have three fragment files X, Y and Z configured. So the update process will only affect Z and be as follows:

1) Create the defconfig Dnow from the current .config file .Cnow:

Dnow = savedefconfig .Cnow

2) Create the .config file .C out of either <PKG>_KCONFIG_DEFCONFIG or <PKG>_KCONFIG_FILE.

3) Merge .C with the two first fragments X and Y into .Cy and create the corresponding defconfig Dy:

.Cy = merge_config.sh .C X Y
Dy = savedefconfig .Cy

4) Collect all items that differ between the two defconfigs Dy and Dnow and take their values from .Cnow:

Znow = diff_defconfig.sh Dy Dnow .Cnow

Now the following holds:

.Cnow = merge_config.sh .C X Y Znow

Znow will only contain configuration items that are visible in defconfigs (see step 4 and the associated script). Also, I assume that Znow will not contain items that are not user-settable because those are not expected to be in defconfigs.

Marcel Patzlaff (3):
Support script for defconfig comparison
Refactoring of pkg-kconfig.mk to increase re-usability New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

 package/pkg-kconfig.mk  | 89 ++++++++++++++++++++++++++++----------
 utils/diff_defconfig.sh | 95 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 161 insertions(+), 23 deletions(-)
 create mode 100755 utils/diff_defconfig.sh
Signature · 9 lines
2.17.1

Gesch?ftsf?hrung: Susanne Kunschert, Thomas Pilz
Pilz GmbH & Co. KG, Sitz: Ostfildern, HRA 210 893, Amtsgericht Stuttgart
Kompl. Ges. Peter Pilz GmbH, Sitz: Ostfildern, HRB 210 612, Amtsgericht Stuttgart
Umsatzsteuer: ID-Nr. DE 145 355 773, WEEE-Reg.-Nr. DE 71636849
This email is intended solely for the use of the named address(es). Any unauthorised disclosure, copying or distribution of these confidential information contained therein, or the taking of any action based on it, is prohibited. The sender disclaims any liability for the integrity of this email. Legally binding declarations must be in written form.
Umweltschutz liegt uns am Herzen! - Bitte denken Sie an unsere Umwelt, bevor Sie diese E-Mail drucken.
We do care about the environment! - Please consider the environment before printing this e-mail.
#1 lore raw

PATCH 1/3 Support script for defconfig comparison

This patch adds a new support script that allows to compare two defconfigs and to output the differences in a form such that it can be used as configuration fragment.

The comparison is done in two steps:

1) Apply a plain "diff" on the two files (A and B) and collect all item names where diff sees a difference. This results in a list of newline separated item names.
2) For each item name in the list, the complete line out of the .config file derived from B is taken and written to stdout.

---
 utils/diff_defconfig.sh | 95 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100755 utils/diff_defconfig.sh
utils/diff_defconfig.sh new file +95 -0
new file mode 100755
index 0000000000..385e741813
@@ -0,0 +1,95 @@
+#!/bin/sh
+
+#  diff_defconfig.sh - Takes two defconfig files A and B as well as the config
+#  file derived from B and outputs the differences that lead from A to B.
+#  The output can be used as configuration fragment.
+#  It is garanteed, that the output only contains configuration items that are
+#  present in either defconfig. So it's assumed, that all configuration items
+#  this script outputs are also user-settable.
+#
+#
+#  Copyright 2018 Pilz GmbH & Co. KG
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License version 2 as
+#  published by the Free Software Foundation.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#  See the GNU General Public License for more details.
+
+set -e
+
+THIS_FILE=$(basename "${0}")
+
+USAGE="${THIS_FILE} [OPTIONS] <a.defconfig> <b.defconfig> <b.config>"
+
+fail_msg() {
+    printf "%s\n" "${1}" 1>&2
+    exit 1
+}
+
+help() {
+    cat <<-_EOF_
+	Usage:
+	    ${USAGE}
+
+	${THIS_FILE} takes two defconfig files A and B as well as the .config
+	file derived from B and outputs the differences that lead from A to B on
+	stdout. The output can be used as configuration fragment.
+
+	Options:
+	    -h   display this help text
+	    -p   do not restrict config prefix to CONFIG_
+
+	Returns:
+	    0    If no error
+	    !0   If any error
+	_EOF_
+}
+
+
+ALLPREFIXES=false
+# parse options
+while true; do
+    case "${1}" in
+        "-h")
+            help
+            exit 0
+        ;;
+        "-p")
+            ALLPREFIXES=true
+            shift
+        ;;
+        *)
+            break
+        ;;
+    esac
+done
+
+# check if all files are given
+[ "${#}" -eq "3" ] || fail_msg "Usage: ${USAGE}"
+
+# test if files exist
+[ -f "${1}" ] || fail_msg "First defconfig file '${1}' does not exist!"
+[ -f "${2}" ] || fail_msg "Second defconfig file '${2}' does not exist!"
+[ -f "${3}" ] || fail_msg "Config file '${3}' does not exist!"
+
+ITEM_EXP="s/^[<>]\s\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p"
+if [ "${ALLPREFIXES}" = "true" ]; then
+    ITEM_EXP="s/^[<>]\s\(# \)\{0,1\}\([a-zA-Z][a-zA-Z0-9_]*\)[= ].*/\2/p"
+fi
+
+# use normal diff and collect all differing item names
+ITEMS=$(diff "${1}" "${2}" | sed -n "${ITEM_EXP}" | sort | uniq)
+
+# output their values
+# Note: ITEMS does only contain newline separators and no other whitespaces.
+#       See regular expression above.
+for item in ${ITEMS}; do
+    # some items disable/hide others so grep may fail here
+    grep -w "${item}" "${3}" || true
+done
+
+exit 0
Signature · 9 lines
2.17.1

Gesch?ftsf?hrung: Susanne Kunschert, Thomas Pilz
Pilz GmbH & Co. KG, Sitz: Ostfildern, HRA 210 893, Amtsgericht Stuttgart
Kompl. Ges. Peter Pilz GmbH, Sitz: Ostfildern, HRB 210 612, Amtsgericht Stuttgart
Umsatzsteuer: ID-Nr. DE 145 355 773, WEEE-Reg.-Nr. DE 71636849
This email is intended solely for the use of the named address(es). Any unauthorised disclosure, copying or distribution of these confidential information contained therein, or the taking of any action based on it, is prohibited. The sender disclaims any liability for the integrity of this email. Legally binding declarations must be in written form.
Umweltschutz liegt uns am Herzen! - Bitte denken Sie an unsere Umwelt, bevor Sie diese E-Mail drucken.
We do care about the environment! - Please consider the environment before printing this e-mail.
#2 lore raw

PATCH 2/3 Refactoring of pkg-kconfig.mk to increase re-usability

In reply to Marcel Patzlaff

This patch refactors savedefconfig and the configuration re-generation to separate macros so that the functionality can be re-used in further targets.

---
 package/pkg-kconfig.mk | 43 ++++++++++++++++++++++++------------------
 1 file changed, 25 insertions(+), 18 deletions(-)
package/pkg-kconfig.mk +25 -18
index 81bba5220c..331ba16614 100644
@@ -27,6 +27,27 @@ define kconfig-package-update-config
 	$(Q)touch --reference $($(PKG)_DIR)/$($(PKG)_KCONFIG_DOTCONFIG) $($(PKG)_KCONFIG_FILE)
 endef
 
+# Macro to save the defconfig file
+define kconfig-package-savedefconfig
+	$($(PKG)_MAKE_ENV) $(MAKE) -C $($(PKG)_DIR) \
+		$($(PKG)_KCONFIG_OPTS) savedefconfig
+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.
+# In older versions, and in some other projects that use kconfig, the target is
+# not supported at all, and we use 'yes "" | make oldconfig' as a fallback
+# only, as this can fail in complex cases.
+# $(1): the name of the package in upper-case letters
+define kconfig-package-regen-dot-config
+	$(if $(filter olddefconfig,$($(1)_KCONFIG_RULES)),
+		$(Q)$($(1)_KCONFIG_MAKE) olddefconfig,
+		$(if $(filter oldnoconfig,$($(1)_KCONFIG_RULES)),
+			$(Q)$($(1)_KCONFIG_MAKE) oldnoconfig,
+			$(Q)(yes "" | $($(1)_KCONFIG_MAKE) oldconfig)))
+endef
+
 ################################################################################
 # inner-kconfig-package -- generates the make targets needed to support a
 # kconfig package
@@ -90,20 +111,6 @@ $(2)_KCONFIG_RULES = \
 	$$(shell $$($(2)_KCONFIG_MAKE) -pn config 2>/dev/null | \
 		sed 's/^\([_0-9a-zA-Z]*config\):.*/\1/ p; d')
 
-# 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.
-# In older versions, and in some other projects that use kconfig, the target is
-# not supported at all, and we use 'yes "" | make oldconfig' as a fallback
-# only, as this can fail in complex cases.
-define $(2)_REGEN_DOT_CONFIG
-	$$(if $$(filter olddefconfig,$$($(2)_KCONFIG_RULES)),
-		$$(Q)$$($(2)_KCONFIG_MAKE) olddefconfig,
-		$$(if $$(filter oldnoconfig,$$($(2)_KCONFIG_RULES)),
-			$$(Q)$$($(2)_KCONFIG_MAKE) oldnoconfig,
-			$$(Q)(yes "" | $$($(2)_KCONFIG_MAKE) oldconfig)))
-endef
-
 # The specified source configuration file and any additional configuration file
 # fragments are merged together to .config, after the package has been patched.
 # Since the file could be a defconfig file it needs to be expanded to a
@@ -114,7 +121,7 @@ $$($(2)_DIR)/$$($(2)_KCONFIG_DOTCONFIG): $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_F
 		$$(INSTALL) -m 0644 -D $$($(2)_KCONFIG_FILE) $$(@))
 	$$(Q)support/kconfig/merge_config.sh -m -O $$(@D) \
 		$$(@) $$($(2)_KCONFIG_FRAGMENT_FILES)
-	$$($(2)_REGEN_DOT_CONFIG)
+	$$(call kconfig-package-regen-dot-config,$(2))
 
 # If _KCONFIG_FILE or _KCONFIG_FRAGMENT_FILES exists, this dependency is
 # already implied, but if we only have a _KCONFIG_DEFCONFIG we have to add
@@ -125,7 +132,7 @@ $$($(2)_DIR)/$$($(2)_KCONFIG_DOTCONFIG): | $(1)-patch
 # The exact rules are specified by the package .mk file.
 define $(2)_FIXUP_DOT_CONFIG
 	$$($(2)_KCONFIG_FIXUP_CMDS)
-	$$($(2)_REGEN_DOT_CONFIG)
+	$$(call kconfig-package-regen-dot-config,$(2))
 	$$(Q)touch $$($(2)_DIR)/.stamp_kconfig_fixup_done
 endef
 
@@ -213,9 +220,9 @@ $(1)-check-configuration-done:
 		exit 1; \
 	fi
 
+$(1)-savedefconfig: PKG=$(2)
 $(1)-savedefconfig: $(1)-check-configuration-done
-	$$($(2)_MAKE_ENV) $$(MAKE) -C $$($(2)_DIR) \
-		$$($(2)_KCONFIG_OPTS) savedefconfig
+	$$(call kconfig-package-savedefconfig)
 
 # Target to copy back the configuration to the source configuration file
 # Even though we could use 'cp --preserve-timestamps' here, the separate
Signature · 9 lines
2.17.1

Gesch?ftsf?hrung: Susanne Kunschert, Thomas Pilz
Pilz GmbH & Co. KG, Sitz: Ostfildern, HRA 210 893, Amtsgericht Stuttgart
Kompl. Ges. Peter Pilz GmbH, Sitz: Ostfildern, HRB 210 612, Amtsgericht Stuttgart
Umsatzsteuer: ID-Nr. DE 145 355 773, WEEE-Reg.-Nr. DE 71636849
This email is intended solely for the use of the named address(es). Any unauthorised disclosure, copying or distribution of these confidential information contained therein, or the taking of any action based on it, is prohibited. The sender disclaims any liability for the integrity of this email. Legally binding declarations must be in written form.
Umweltschutz liegt uns am Herzen! - Bitte denken Sie an unsere Umwelt, bevor Sie diese E-Mail drucken.
We do care about the environment! - Please consider the environment before printing this e-mail.
#3 lore raw

PATCH 3/3 New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

In reply to Marcel Patzlaff

This patch adds the new target above which implements the update routine as detailled in the head of this patch series.

---
 package/pkg-kconfig.mk | 48 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 42 insertions(+), 6 deletions(-)
package/pkg-kconfig.mk +42 -6
index 331ba16614..bc817c457f 100644
@@ -48,6 +48,18 @@ define kconfig-package-regen-dot-config
 			$(Q)(yes "" | $($(1)_KCONFIG_MAKE) oldconfig)))
 endef
 
+# Macro to create a .config file where all fragments are merged into
+# $(1): the name of the package in upper-case letters
+# $(2): name of the .config file
+# $(3): fragment files to merge
+define kconfig-package-merge-config
+	$(Q)$(if $($(1)_KCONFIG_DEFCONFIG),\
+		$($(1)_KCONFIG_MAKE) $($(1)_KCONFIG_DEFCONFIG),\
+		$(INSTALL) -m 0644 -D $($(1)_KCONFIG_FILE) $(2))
+	$(Q)support/kconfig/merge_config.sh -m -O $(@D) $(2) $(3)
+	$(call kconfig-package-regen-dot-config,$(1))
+endef
+
 ################################################################################
 # inner-kconfig-package -- generates the make targets needed to support a
 # kconfig package
@@ -116,12 +128,7 @@ $(2)_KCONFIG_RULES = \
 # Since the file could be a defconfig file it needs to be expanded to a
 # full .config first.
 $$($(2)_DIR)/$$($(2)_KCONFIG_DOTCONFIG): $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES)
-	$$(Q)$$(if $$($(2)_KCONFIG_DEFCONFIG), \
-		$$($(2)_KCONFIG_MAKE) $$($(2)_KCONFIG_DEFCONFIG), \
-		$$(INSTALL) -m 0644 -D $$($(2)_KCONFIG_FILE) $$(@))
-	$$(Q)support/kconfig/merge_config.sh -m -O $$(@D) \
-		$$(@) $$($(2)_KCONFIG_FRAGMENT_FILES)
-	$$(call kconfig-package-regen-dot-config,$(2))
+	$$(call kconfig-package-merge-config,$(2),$$(@),$$($(2)_KCONFIG_FRAGMENT_FILES))
 
 # If _KCONFIG_FILE or _KCONFIG_FRAGMENT_FILES exists, this dependency is
 # already implied, but if we only have a _KCONFIG_DEFCONFIG we have to add
@@ -239,11 +246,40 @@ $(1)-update-defconfig: PKG=$(2)
 $(1)-update-defconfig: $(1)-savedefconfig
 	$$(call kconfig-package-update-config,defconfig)
 
+
+define $(2)_KCONFIG_LAST_FRAGMENT
+	$$(lastword $$($(2)_KCONFIG_FRAGMENT_FILES))
+endef
+
+define $(2)_KCONFIG_FIRST_FRAGMENTS
+	$$(filter-out $$($(2)_KCONFIG_LAST_FRAGMENT),\
+		$$($(2)_KCONFIG_FRAGMENT_FILES))
+endef
+
+$(1)-update-last-config-fragment: PKG=$(2)
+$(1)-update-last-config-fragment: $(1)-savedefconfig
+	@$$(if $$($(2)_KCONFIG_FRAGMENT_FILES), true, \
+		echo "Unable to perform $(@) when no fragment files are set"; exit 1)
+	$$(Q)cp -a $$($(2)_DIR)/$$($(2)_KCONFIG_DOTCONFIG) $$($(2)_DIR)/.config.ulcf.all
+	$$(Q)cp -a $$($(2)_DIR)/defconfig $$($(2)_DIR)/defconfig.ulcf.all
+	$$(call kconfig-package-merge-config,$(2),$$($(2)_KCONFIG_DOTCONFIG),\
+		$$($(2)_KCONFIG_FIRST_FRAGMENTS))
+	$$(call kconfig-package-savedefconfig)
+	$$(Q)cp -a $$($(2)_DIR)/defconfig $$($(2)_DIR)/defconfig.ulcf.first
+	$$(Q)cp -a $$($(2)_DIR)/.config.ulcf.all $$($(2)_DIR)/$$($(2)_KCONFIG_DOTCONFIG)
+	$$(Q)cp -a $$($(2)_DIR)/defconfig.ulcf.all $$($(2)_DIR)/defconfig
+	$$(Q)utils/diff_defconfig.sh $$($(2)_DIR)/defconfig.ulcf.first \
+		$$($(2)_DIR)/defconfig.ulcf.all $$($(2)_DIR)/.config.ulcf.all > \
+		$$($(2)_KCONFIG_LAST_FRAGMENT)
+	$$(Q)rm -f $$($(2)_DIR)/defconfig.ulcf.* $$($(2)_DIR)/.config.ulcf.*
+
+
 endif # package enabled
 
 .PHONY: \
 	$(1)-update-config \
 	$(1)-update-defconfig \
+	$(1)-update-last-config-fragment \
 	$(1)-savedefconfig \
 	$(1)-check-configuration-done \
 	$$($(2)_DIR)/.kconfig_editor_% \
Signature · 9 lines
2.17.1

Gesch?ftsf?hrung: Susanne Kunschert, Thomas Pilz
Pilz GmbH & Co. KG, Sitz: Ostfildern, HRA 210 893, Amtsgericht Stuttgart
Kompl. Ges. Peter Pilz GmbH, Sitz: Ostfildern, HRB 210 612, Amtsgericht Stuttgart
Umsatzsteuer: ID-Nr. DE 145 355 773, WEEE-Reg.-Nr. DE 71636849
This email is intended solely for the use of the named address(es). Any unauthorised disclosure, copying or distribution of these confidential information contained therein, or the taking of any action based on it, is prohibited. The sender disclaims any liability for the integrity of this email. Legally binding declarations must be in written form.
Umweltschutz liegt uns am Herzen! - Bitte denken Sie an unsere Umwelt, bevor Sie diese E-Mail drucken.
We do care about the environment! - Please consider the environment before printing this e-mail.
#4 lore raw

PATCH 3/3 New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

Hello Marcel,

Quoted 4 lines · Marcel Patzlaff

This patch adds the new target above which implements the update routine as detailled in the head of this patch series.

Thanks for working on this complex topic, as Arnout said.

On my side, I find the semantic of "let's update the _last_ fragment" to be a bit weird and complex to understand. Why the last one, and not any other ?

I'm not sure it's possible to have something that updates fragments with a sensible semantic.

However, what would be useful would be a way to dump the difference between the current configuration, and what the combination of the defconfig+fragments provide.

I.e, you start Buildroot with omap2plus_defconfig + some specific fragments as the kernel configuration.

You run "make linux-show-config-diff", which returns empty.

Then you tweak the configuration with "make linux-menuconfig", and run "make linux-show-config-diff", which shows you the lines that you need to put in one of your fragments to preserve the configuration tweaks you have done.

Of course, the name "linux-show-config-diff" is just made up here, and some more thought is needed to find a good name. But overall, I believe the semantic would be much clearer, and doesn't make any assumption on whether we have one or several fragments, and whether the last fragment or any other fragment needs to be updated.

What do you think about this? Would this also fill your needs?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

[Buildroot] Antwort: Re: [PATCH 3/3] New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

Hello Thomas,

Quoted 10 lines

Hello Marcel,

Thanks for working on this complex topic, as Arnout said.

On my side, I find the semantic of "let's update the _last_ fragment" to be a bit weird and complex to understand. Why the last one, and not any other ?

I'm not sure it's possible to have something that updates fragments with a sensible semantic.

Well, it should just reflect what the merge_config script does: the last file in the list of files to be merged always overrides settings done in files before. So this means, that the last fragment is basically the most significate one.

When I think about it, this should also be documented somewhere. Because the result with configuration fragments A, B, C could be different than B, A, C for example. So it should definitely be told, that the order of fragments matters and that the fragments are best used to specialise the configuration of other "layers" before.

Quoted 14 lines

However, what would be useful would be a way to dump the difference between the current configuration, and what the combination of the defconfig+fragments provide.

I.e, you start Buildroot with omap2plus_defconfig + some specific fragments as the kernel configuration.

You run "make linux-show-config-diff", which returns empty.

Then you tweak the configuration with "make linux-menuconfig", and run "make linux-show-config-diff", which shows you the lines that you need to put in one of your fragments to preserve the configuration tweaks you have done.

Quoted 7 lines

Of course, the name "linux-show-config-diff" is just made up here, and some more thought is needed to find a good name. But overall, I believe the semantic would be much clearer, and doesn't make any assumption on whether we have one or several fragments, and whether the last fragment or any other fragment needs to be updated.

What do you think about this? Would this also fill your needs?

Despite the fact, that you now have to put this diff manually somewhere it would not change things. Because this diff, as I pointed out above, is in general only useful for the last fragment.
Updating any other fragment in the list would require either to have no dependencies between fragments at all (too restrictive at least for my use cases and also I'm not sure that this is feasible) or to have a deep understanding of the dependencies.
From my perspective, neither option is that encouraging, so I do not want to propose a way to update any fragment other than the last one.

Regards,
Marcel

Gesch?ftsf?hrung: Susanne Kunschert, Thomas Pilz
Pilz GmbH & Co. KG, Sitz: Ostfildern, HRA 210 893, Amtsgericht Stuttgart
Kompl. Ges. Peter Pilz GmbH, Sitz: Ostfildern, HRB 210 612, Amtsgericht Stuttgart
Umsatzsteuer: ID-Nr. DE 145 355 773, WEEE-Reg.-Nr. DE 71636849
This email is intended solely for the use of the named address(es). Any unauthorised disclosure, copying or distribution of these confidential information contained therein, or the taking of any action based on it, is prohibited. The sender disclaims any liability for the integrity of this email. Legally binding declarations must be in written form. Umweltschutz liegt uns am Herzen! - Bitte denken Sie an unsere Umwelt, bevor Sie diese E-Mail drucken.
We do care about the environment! - Please consider the environment before printing this e-mail.

#6 lore raw

PATCH 3/3 New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

Hello Marcel,

Quoted 6 lines · Marcel Patzlaff

Hello Thomas,

Quoted 4 lines

On my side, I find the semantic of "let's update the _last_ fragment" to be a bit weird and complex to understand. Why the last one, and not any other ?

Quoted 7 lines
Quoted 2 lines

I'm not sure it's possible to have something that updates fragments with a sensible semantic.

Well, it should just reflect what the merge_config script does: the last file in the list of files to be merged always overrides settings done in files before. So this means, that the last fragment is basically the most significate one.

Fragments are not about "priority", they are typically about splitting by topic different aspects. So it is not because the last fragment overrides the configuration options of other fragments that a configuration change you just did to enable driver FOO should go in the last fragment.

Quoted 5 lines

When I think about it, this should also be documented somewhere. Because the result with configuration fragments A, B, C could be different than B, A, C for example. So it should definitely be told, that the order of fragments matters and that the fragments are best used to specialise the configuration of other "layers" before.

This can be documented in the Config.in help text of the BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES option (ditto for U-Boot, etc.).

Quoted 20 lines
Quoted 20 lines

However, what would be useful would be a way to dump the difference between the current configuration, and what the combination of the defconfig+fragments provide.

I.e, you start Buildroot with omap2plus_defconfig + some specific fragments as the kernel configuration.

You run "make linux-show-config-diff", which returns empty.

Then you tweak the configuration with "make linux-menuconfig", and run "make linux-show-config-diff", which shows you the lines that you need to put in one of your fragments to preserve the configuration tweaks you have done.

Of course, the name "linux-show-config-diff" is just made up here, and some more thought is needed to find a good name. But overall, I believe the semantic would be much clearer, and doesn't make any assumption on whether we have one or several fragments, and whether the last fragment or any other fragment needs to be updated.

Quoted 5 lines
Quoted 1 line

What do you think about this? Would this also fill your needs?

Despite the fact, that you now have to put this diff manually somewhere it would not change things. Because this diff, as I pointed out above, is in general only useful for the last fragment.

Not at all, as explained above. You enabled driver FOO, it may need to go to the last fragment, or potentially to any other fragment, it really depends on how the fragments are organized.

Quoted 4 lines

Updating any other fragment in the list would require either to have no dependencies between fragments at all (too restrictive at least for my use cases and also I'm not sure that this is feasible) or to have a deep understanding of the dependencies.

When someone is using fragments, then they understand what they mean to split the configuration in different snippets. People who don't understand that will typically use a single monolithic .config file.

Quoted 2 lines

From my perspective, neither option is that encouraging, so I do not want to propose a way to update any fragment other than the last one.

My position is that updating anything is not correct, because you cannot know whether it is the last fragment or any of the other fragment that needs to be updated. The only sane semantic is to show what the differences are, and let the user figure out where these configuration differences should be propagated.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#7 lore raw

[Buildroot] Antwort: Re: [PATCH 3/3] New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

Quoted 1 line
Quoted 1 line

Well, it should just reflect what the merge_config script does: the

last

Quoted 1 line
Quoted 1 line

file in the list of files to be merged always overrides settings done

in

Quoted 8 lines
Quoted 2 lines

files before. So this means, that the last fragment is basically the most significate one.

Fragments are not about "priority", they are typically about splitting by topic different aspects. So it is not because the last fragment overrides the configuration options of other fragments that a configuration change you just did to enable driver FOO should go in the last fragment.

Fair enough, that's a use case where you most probably do not want to use the proposed automatism. But if you exploit the layered customisations (through BR2_EXTERNAL) and associate at most one fragment with each layer than you know which layer to update and you can make use of the proposed feature. That's at least how we are using it here. It would then just be analogous to <pkg>-update-defconfig in the first layer.

Quoted 1 line
Quoted 1 line

Updating any other fragment in the list would require either to have

no

Quoted 2 lines
Quoted 2 lines

dependencies between fragments at all (too restrictive at least for my use cases and also I'm not sure that this is feasible) or to have a

deep

Quoted 5 lines
Quoted 1 line

understanding of the dependencies.

When someone is using fragments, then they understand what they mean to split the configuration in different snippets. People who don't understand that will typically use a single monolithic .config file.

Of course one can keep it that way. But with the proposed change here it does not have to.

Quoted 8 lines
Quoted 2 lines

From my perspective, neither option is that encouraging, so I do not want to propose a way to update any fragment other than the last one.

My position is that updating anything is not correct, because you cannot know whether it is the last fragment or any of the other fragment that needs to be updated. The only sane semantic is to show what the differences are, and let the user figure out where these configuration differences should be propagated.

The target clearily states what it updates. So for use cases where this is not meaningful it may of course not be used.

If this change set is targeted at too specific use cases or does only solve one specific need, then well you should reject it. I am not sure about that because I only see how buildroot is used in-house. And from that perspective there is really a need for it.

So at last, I do not have a problem withdrawing the patch series and keep maintaining it in-house. I only have to know if there is interest in it outside or not.

Kind regards,
Marcel

Gesch?ftsf?hrung: Susanne Kunschert, Thomas Pilz
Pilz GmbH & Co. KG, Sitz: Ostfildern, HRA 210 893, Amtsgericht Stuttgart
Kompl. Ges. Peter Pilz GmbH, Sitz: Ostfildern, HRB 210 612, Amtsgericht Stuttgart
Umsatzsteuer: ID-Nr. DE 145 355 773, WEEE-Reg.-Nr. DE 71636849
This email is intended solely for the use of the named address(es). Any unauthorised disclosure, copying or distribution of these confidential information contained therein, or the taking of any action based on it, is prohibited. The sender disclaims any liability for the integrity of this email. Legally binding declarations must be in written form. Umweltschutz liegt uns am Herzen! - Bitte denken Sie an unsere Umwelt, bevor Sie diese E-Mail drucken.
We do care about the environment! - Please consider the environment before printing this e-mail.

#8 lore raw

PATCH 3/3 New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

In reply to Thomas Petazzoni

Thomas, Marcel, All,

On 2018-07-30 23:46 +0200, Thomas Petazzoni spake thusly:

Quoted 29 lines · Marcel Patzlaff
Quoted 4 lines

This patch adds the new target above which implements the update routine as detailled in the head of this patch series.

Thanks for working on this complex topic, as Arnout said.

On my side, I find the semantic of "let's update the _last_ fragment" to be a bit weird and complex to understand. Why the last one, and not any other ?

I'm not sure it's possible to have something that updates fragments with a sensible semantic.

However, what would be useful would be a way to dump the difference between the current configuration, and what the combination of the defconfig+fragments provide.

I.e, you start Buildroot with omap2plus_defconfig + some specific fragments as the kernel configuration.

You run "make linux-show-config-diff", which returns empty.

Then you tweak the configuration with "make linux-menuconfig", and run "make linux-show-config-diff", which shows you the lines that you need to put in one of your fragments to preserve the configuration tweaks you have done.

Quoted 7 lines

Of course, the name "linux-show-config-diff" is just made up here, and some more thought is needed to find a good name. But overall, I believe the semantic would be much clearer, and doesn't make any assumption on whether we have one or several fragments, and whether the last fragment or any other fragment needs to be updated.

What do you think about this? Would this also fill your needs?

I would advocate that we do a generic solution like Thomas suggests, because it is generic enough that it would help solve more use-cases than this patch does.

So, I side with Thomas here.

I would just suggest that we do not add any new rule, but trying to update the defconfig when there are fragments would fail as it currently does, but also would display the delta if there is one. I.e.:

    $ make linux-menuconfig
    [change stuff]
    $ make linux-update-defconfig
    Unable to perform linux-update-defconfig when fragment files are set
    Configuration changes that you want to propagate to one of the fragments:
    -CONFIG_FOO=y
    +# CONFIG_BAR is unset
    linux/linux.mk:511: recipe for target 'linux-update-defconfig' failed
    make[1]: *** [linux-update-defconfig] Error 1

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#9 lore raw

PATCH 3/3 New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

Hello,

Adding Arnout and Peter in Cc, in case they want to give their opinion on the patch series.

Quoted 4 lines · Yann E. MORIN

I would just suggest that we do not add any new rule, but trying to update the defconfig when there are fragments would fail as it currently does, but also would display the delta if there is one. I.e.:

Quoted 9 lines
    $ make linux-menuconfig
    [change stuff]
    $ make linux-update-defconfig
    Unable to perform linux-update-defconfig when fragment files are set
    Configuration changes that you want to propagate to one of the fragments:
    -CONFIG_FOO=y
    +# CONFIG_BAR is unset
    linux/linux.mk:511: recipe for target 'linux-update-defconfig' failed
    make[1]: *** [linux-update-defconfig] Error 1

I think we could do that in *addition* to having a new rule. Indeed, when you know what you're doing, having to run something that doesn't make sense ("make linux-update-defconfig") and which causes a failure is a bit silly. I'd rather run "make linux-diff-config" (or whatever name we chose).

Marcel, do you think you could rework your patch series to go in the direction of showing a diff rather than arbitrarily adjusting the last fragment ?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#10 lore raw

PATCH 3/3 New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

Thomas, Marcel, All,

On 2018-08-14 16:27 +0200, Thomas Petazzoni spake thusly:

Quoted 17 lines

Adding Arnout and Peter in Cc, in case they want to give their opinion on the patch series.

Quoted 4 lines · Yann E. MORIN

I would just suggest that we do not add any new rule, but trying to update the defconfig when there are fragments would fail as it currently does, but also would display the delta if there is one. I.e.:

Quoted 9 lines
    $ make linux-menuconfig
    [change stuff]
    $ make linux-update-defconfig
    Unable to perform linux-update-defconfig when fragment files are set
    Configuration changes that you want to propagate to one of the fragments:
    -CONFIG_FOO=y
    +# CONFIG_BAR is unset
    linux/linux.mk:511: recipe for target 'linux-update-defconfig' failed
    make[1]: *** [linux-update-defconfig] Error 1
Quoted 5 lines

I think we could do that in *addition* to having a new rule. Indeed, when you know what you're doing, having to run something that doesn't make sense ("make linux-update-defconfig") and which causes a failure is a bit silly. I'd rather run "make linux-diff-config" (or whatever name we chose).

OK by me.

Quoted 3 lines

Marcel, do you think you could rework your patch series to go in the direction of showing a diff rather than arbitrarily adjusting the last fragment ?

Yes, please! ;-)

Regards,
Yann E. MORIN.

Quoted 7 lines

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#11 lore raw

PATCH 3/3 New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

In reply to Thomas Petazzoni
Quoted 27 lines · Thomas Petazzoni

Hello,

Adding Arnout and Peter in Cc, in case they want to give their opinion on the patch series.

Quoted 4 lines · Yann E. MORIN

I would just suggest that we do not add any new rule, but trying to update the defconfig when there are fragments would fail as it currently does, but also would display the delta if there is one. I.e.:

Quoted 9 lines
    $ make linux-menuconfig
    [change stuff]
    $ make linux-update-defconfig
    Unable to perform linux-update-defconfig when fragment files are set
    Configuration changes that you want to propagate to one of the fragments:
    -CONFIG_FOO=y
    +# CONFIG_BAR is unset
    linux/linux.mk:511: recipe for target 'linux-update-defconfig' failed
    make[1]: *** [linux-update-defconfig] Error 1

I think we could do that in *addition* to having a new rule. Indeed, when you know what you're doing, having to run something that doesn't make sense ("make linux-update-defconfig") and which causes a failure is a bit silly. I'd rather run "make linux-diff-config" (or whatever name we chose).

Quoted 3 lines

Marcel, do you think you could rework your patch series to go in the direction of showing a diff rather than arbitrarily adjusting the last fragment ?

Note that the diff really applies to the last fragment only, in the sense that
if the last fragment is setting CONFIG_BAR, the "is unset" bit has to come after it. I don't think there is a way to say anything sensible automatically except for the last fragment.

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#12 lore raw

PATCH 3/3 New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

Hello,

Quoted 8 lines · Arnout Vandecappelle
Quoted 3 lines

Marcel, do you think you could rework your patch series to go in the direction of showing a diff rather than arbitrarily adjusting the last fragment ?

Note that the diff really applies to the last fragment only, in the sense that
if the last fragment is setting CONFIG_BAR, the "is unset" bit has to come after it. I don't think there is a way to say anything sensible automatically except for the last fragment.

Yes, the diff cannot be blindly applied to anything but the last fragment. But the idea in showing the diff is not for the user to apply it blindly, but rather to determine which parts of the diff should be reflected to each fragment.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#13 lore raw

PATCH 3/3 New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

Thomas, Arnout, Marcel, All,

On 2018-08-15 14:04 +0200, Thomas Petazzoni spake thusly:

Quoted 10 lines · Arnout Vandecappelle
Quoted 8 lines
Quoted 3 lines

Marcel, do you think you could rework your patch series to go in the direction of showing a diff rather than arbitrarily adjusting the last fragment ?

Note that the diff really applies to the last fragment only, in the sense that
if the last fragment is setting CONFIG_BAR, the "is unset" bit has to come after it. I don't think there is a way to say anything sensible automatically except for the last fragment.

Quoted 4 lines

Yes, the diff cannot be blindly applied to anything but the last fragment. But the idea in showing the diff is not for the user to apply it blindly, but rather to determine which parts of the diff should be reflected to each fragment.

Indeed, it is not to be considered to be a diff of any of the fragment, but of the configuration *as a whole*.

That's why I initially did not write a full diff, but only the delta snippet, not the context, because it is a diff, not a patch.

But I think we should instead use the scripts/diffconfig script that is in the linux kernel tree, and which outputs looks like:

    $ cat config.000
    CONFIG_FOO=y
    $ cat config.001
    CONFIG_FOO is not set
    $ ./scripts/diffconfig config.000 config.001
     FOO y -> n

which IMNSHO is exactly the message we want to convey.

Regards,
Yann E. MORIN.

Quoted 7 lines

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#14 lore raw

PATCH 3/3 New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

Hello,

Quoted 9 lines · Yann E. MORIN

Indeed, it is not to be considered to be a diff of any of the fragment, but of the configuration *as a whole*.

That's why I initially did not write a full diff, but only the delta snippet, not the context, because it is a diff, not a patch.

But I think we should instead use the scripts/diffconfig script that is in the linux kernel tree, and which outputs looks like:

Quoted 8 lines
    $ cat config.000
    CONFIG_FOO=y
    $ cat config.001
    CONFIG_FOO is not set
    $ ./scripts/diffconfig config.000 config.001
     FOO y -> n

which IMNSHO is exactly the message we want to convey.

Indeed, this looks very good, and diffconfig is an existing tool.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#15 lore raw

PATCH 3/3 New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

Thomas, All,

On 2018-08-15 19:35 +0200, Thomas Petazzoni spake thusly:

Quoted 17 lines · Yann E. MORIN
Quoted 16 lines

Indeed, it is not to be considered to be a diff of any of the fragment, but of the configuration *as a whole*.

That's why I initially did not write a full diff, but only the delta snippet, not the context, because it is a diff, not a patch.

But I think we should instead use the scripts/diffconfig script that is in the linux kernel tree, and which outputs looks like:

    $ cat config.000
    CONFIG_FOO=y
    $ cat config.001
    CONFIG_FOO is not set
    $ ./scripts/diffconfig config.000 config.001
     FOO y -> n
Quoted 3 lines
Quoted 1 line

which IMNSHO is exactly the message we want to convey.

Indeed, this looks very good, and diffconfig is an existing tool.

Note that this was the diffconfig tool frm the kernel. The one we have behave differently (and badly I think), given the same config files as input:

    $ ./utils/diffconfig linux-config.000 linux-config.001
    +IG_FOO n

Which is not nice... :-/

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#16 lore raw

PATCH 3/3 New <pkg>-update-last-config-fragment target in pkg-kconfig.mk

Hello,

Quoted 10 lines · Yann E. MORIN
Quoted 1 line

Indeed, this looks very good, and diffconfig is an existing tool.

Note that this was the diffconfig tool frm the kernel. The one we have behave differently (and badly I think), given the same config files as input:

    $ ./utils/diffconfig linux-config.000 linux-config.001
    +IG_FOO n

Which is not nice... :-/

Well, I guess we can import the diffconfig from the kernel, no?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com