[FE training-materials-updates] buildroot: add patches to fix linux-update-config issue

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Mon Jun 15 10:40:27 CEST 2015


Repository : git://git.free-electrons.com/training-materials.git

On branch  : master
Link       : http://git.free-electrons.com/training-materials/commit/?id=42a4b05196af53b543cc52edb7b4a4dec2cf3fa1

>---------------------------------------------------------------

commit 42a4b05196af53b543cc52edb7b4a4dec2cf3fa1
Author: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
Date:   Mon Jun 15 10:40:19 2015 +0200

    buildroot: add patches to fix linux-update-config issue
    
    Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>


>---------------------------------------------------------------

42a4b05196af53b543cc52edb7b4a4dec2cf3fa1
 ...onfig-ensure-kconfig-base-and-fragment-fi.patch | 89 +++++++++++++++++++++
 ...config-move-the-kconfig-fixups-to-a-macro.patch | 41 ++++++++++
 ...onfig-run-the-kconfig-fixups-after-exitin.patch | 60 +++++++++++++++
 ...onfig-allow-saving-config-to-a-non-existi.patch | 90 ++++++++++++++++++++++
 .../{ => linux}/0001-Add-nunchuk-driver.patch      |  0
 .../0002-Add-i2c1-and-nunchuk-nodes-in-dts.patch   |  0
 6 files changed, 280 insertions(+)

diff --git a/lab-data/buildroot/buildroot-rootfs/buildroot/0001-core-pkg-kconfig-ensure-kconfig-base-and-fragment-fi.patch b/lab-data/buildroot/buildroot-rootfs/buildroot/0001-core-pkg-kconfig-ensure-kconfig-base-and-fragment-fi.patch
new file mode 100644
index 0000000..88be11a
--- /dev/null
+++ b/lab-data/buildroot/buildroot-rootfs/buildroot/0001-core-pkg-kconfig-ensure-kconfig-base-and-fragment-fi.patch
@@ -0,0 +1,89 @@
+From d1d7f84e805e18d927889b30e7cb90b610db24ec Mon Sep 17 00:00:00 2001
+From: "Yann E. MORIN" <yann.morin.1998 at free.fr>
+Date: Sat, 13 Jun 2015 18:46:34 +0200
+Subject: [PATCH] core/pkg-kconfig: ensure kconfig base and fragment files
+ exist
+
+Even though we do have a dependency chain back to each of the kconfig
+base and fragment files:
+
+    $$($(2)_DIR)/.config: $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES)
+
+we can't rely on it to ensure they are all present, because they all have
+this rule:
+
+    $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES): | $(1)-patch
+
+but since this rule has no prerequisite (only build-order, but that does
+not count in this case) and no recipe, make will believe each missing
+file to be a PHONY target, and will always run targets that depend on
+it:
+    https://www.gnu.org/software/make/manual/make.html#Force-Targets
+
+So, that means a missing kconfig base or fragment file would always
+cause the rule to generate .config to be run at each invocation, which
+in turn would cause a rebuild of the kernel, which is clearly not what
+we want.
+
+Since this is expected make behaviour, we can well end up with a missing
+Kconfig base or fragment. To avoid continuously rebuilding the kernel in
+that case, we must check those files exist by ourselves, and error out
+if any one of them is missing.
+
+One would expect we check for them right in their dependency rule, like
+so:
+
+    $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES): | $(1)-patch
+        [ -f $(@) ] || {echo Missing $(@) >&2; exit 1; }
+
+but that does not work, as only the first target is tested for. That
+check msut be turned into a loop explicitly testing all files, like so:
+
+    $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES): | $(1)-patch
+        for f in $$($(2)_KCONFIG_FILE) $$($(2)_KCONFIG_FRAGMENT_FILES); do \
+            [ -f $(@) ] || {echo Missing $$$${f} >&2; exit 1; }; \
+        done
+
+Signed-off-by: "Yann E. MORIN" <yann.morin.1998 at free.fr>
+Cc: Floris Bos <bos at je-eigen-domein.nl>
+Cc: Thomas De Schampheleire <patrickdepinguin at gmail.com>
+Cc: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
+---
+ package/pkg-kconfig.mk | 20 ++++++++++++++++++++
+ 1 file changed, 20 insertions(+)
+
+diff --git a/package/pkg-kconfig.mk b/package/pkg-kconfig.mk
+index ec58d69..d3c411f 100644
+--- a/package/pkg-kconfig.mk
++++ b/package/pkg-kconfig.mk
+@@ -41,6 +41,26 @@ ifndef $(2)_KCONFIG_FILE
+ $$(error Internal error: no value specified for $(2)_KCONFIG_FILE)
+ endif
+ 
++# The config file as well as the fragments could be in-tree, so before
++# depending on them the package should be extracted (and patched) first.
++#
++# Since those files only have a order-only dependency, make would treat
++# any missing one as a "force" target:
++#   https://www.gnu.org/software/make/manual/make.html#Force-Targets
++# and would forcibly any rule that depend on those files, causing a
++# rebuild of the kernel each time make is called.
++#
++# So, we provide a recipe that checks all of those files exist, to
++# overcome that standard make behaviour.
++#
++$$($(2)_KCONFIG_FILE): | $(1)-patch
++	for f in $$($(2)_KCONFIG_FILE); do \
++		if [ ! -f "$$$${f}" ]; then \
++			printf "Kconfig fragment '%s' for '%s' does not exist\n" "$$$${f}" "$(1)"; \
++			exit 1; \
++		fi; \
++	done
++
+ # The .config file is obtained by copying it from the specified source
+ # configuration file, after the package has been patched.
+ $$($(2)_DIR)/.config: $$($(2)_KCONFIG_FILE) | $(1)-patch
+-- 
+2.1.0
+
diff --git a/lab-data/buildroot/buildroot-rootfs/buildroot/0002-core-pkg-kconfig-move-the-kconfig-fixups-to-a-macro.patch b/lab-data/buildroot/buildroot-rootfs/buildroot/0002-core-pkg-kconfig-move-the-kconfig-fixups-to-a-macro.patch
new file mode 100644
index 0000000..5d23701
--- /dev/null
+++ b/lab-data/buildroot/buildroot-rootfs/buildroot/0002-core-pkg-kconfig-move-the-kconfig-fixups-to-a-macro.patch
@@ -0,0 +1,41 @@
+From c3fbd3753851a21fe9edf08eb417bd550b000009 Mon Sep 17 00:00:00 2001
+From: "Yann E. MORIN" <yann.morin.1998 at free.fr>
+Date: Sat, 13 Jun 2015 18:46:35 +0200
+Subject: [PATCH] core/pkg-kconfig: move the kconfig fixups to a macro
+
+The same fixups will have to be done after leaving the configurators,
+so we want to commonalise that code.
+
+Signed-off-by: "Yann E. MORIN" <yann.morin.1998 at free.fr>
+Cc: Thomas De Schampheleire <patrickdepinguin at gmail.com>
+Cc: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
+---
+ package/pkg-kconfig.mk | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/package/pkg-kconfig.mk b/package/pkg-kconfig.mk
+index d3c411f..9288450 100644
+--- a/package/pkg-kconfig.mk
++++ b/package/pkg-kconfig.mk
+@@ -68,11 +68,15 @@ $$($(2)_DIR)/.config: $$($(2)_KCONFIG_FILE) | $(1)-patch
+ 
+ # In order to get a usable, consistent configuration, some fixup may be needed.
+ # The exact rules are specified by the package .mk file.
+-$$($(2)_DIR)/.stamp_kconfig_fixup_done: $$($(2)_DIR)/.config
++define $(2)_FIXUP_DOT_CONFIG
+ 	$$($(2)_KCONFIG_FIXUP_CMDS)
+ 	@yes "" | $$($(2)_MAKE_ENV) $$(MAKE) -C $$($(2)_DIR) \
+ 		$$($(2)_KCONFIG_OPTS) oldconfig
+-	$$(Q)touch $$@
++	$$(Q)touch $$($(2)_DIR)/.stamp_kconfig_fixup_done
++endef
++
++$$($(2)_DIR)/.stamp_kconfig_fixup_done: $$($(2)_DIR)/.config
++	$$(call $(2)_FIXUP_DOT_CONFIG)
+ 
+ # Before running configure, the configuration file should be present and fixed
+ $$($(2)_TARGET_CONFIGURE): $$($(2)_DIR)/.stamp_kconfig_fixup_done
+-- 
+2.1.0
+
diff --git a/lab-data/buildroot/buildroot-rootfs/buildroot/0003-core-pkg-kconfig-run-the-kconfig-fixups-after-exitin.patch b/lab-data/buildroot/buildroot-rootfs/buildroot/0003-core-pkg-kconfig-run-the-kconfig-fixups-after-exitin.patch
new file mode 100644
index 0000000..3c94824
--- /dev/null
+++ b/lab-data/buildroot/buildroot-rootfs/buildroot/0003-core-pkg-kconfig-run-the-kconfig-fixups-after-exitin.patch
@@ -0,0 +1,60 @@
+From 23c50a963a66d43bb9470a1888ce4590ce50f6e1 Mon Sep 17 00:00:00 2001
+From: "Yann E. MORIN" <yann.morin.1998 at free.fr>
+Date: Sat, 13 Jun 2015 18:46:36 +0200
+Subject: [PATCH] core/pkg-kconfig: run the kconfig fixups after exiting
+ configurators
+
+After we exit the configurators, we need to re-run the kconfig fixups to
+ensure the user is not able to override them in the configurators.
+
+Currently, we schedule that "for later", by removing the corresponding
+stamp file, so make will run the fixups "later".
+
+This means the user has access to the un-fixed .config file, which he
+might decide to copy and use as a reference (not too bad, since we'd run
+the fixups anyway; but not clean either).
+
+Note that we still remove the stamp file before running the fixups, in
+case any one of those fixups breaks, so we don't want to believe the
+fixups have been applied; the fixup macro will touch that file anyway.
+
+Signed-off-by: "Yann E. MORIN" <yann.morin.1998 at free.fr>
+Cc: Thomas De Schampheleire <patrickdepinguin at gmail.com>
+Cc: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
+---
+ package/pkg-kconfig.mk | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/package/pkg-kconfig.mk b/package/pkg-kconfig.mk
+index 9288450..fceff51 100644
+--- a/package/pkg-kconfig.mk
++++ b/package/pkg-kconfig.mk
+@@ -82,11 +82,24 @@ $$($(2)_DIR)/.stamp_kconfig_fixup_done: $$($(2)_DIR)/.config
+ $$($(2)_TARGET_CONFIGURE): $$($(2)_DIR)/.stamp_kconfig_fixup_done
+ 
+ # Configuration editors (menuconfig, ...)
++#
++# Apply the kconfig fixups right after exiting the configurators, so
++# that the user always sees a .config file that is clean wrt. our
++# requirements.
++#
++# Because commands in $(1)_FIXUP_KCONFIG are probably using $(@D), we
++# fake it for the configurators (otherwise it is set to just '.', i.e.
++# the current directory where make is run, which happens to be in
++# $(TOPDIR), because the target of the rule is not an actual file, so
++# does not have any path component).
++#
++$$(addprefix $(1)-,$$($(2)_KCONFIG_EDITORS)): @D=$$($(2)_DIR)
+ $$(addprefix $(1)-,$$($(2)_KCONFIG_EDITORS)): $$($(2)_DIR)/.stamp_kconfig_fixup_done
+ 	$$($(2)_MAKE_ENV) $$(MAKE) -C $$($(2)_DIR) \
+ 		$$($(2)_KCONFIG_OPTS) $$(subst $(1)-,,$$@)
+ 	rm -f $$($(2)_DIR)/.stamp_{kconfig_fixup_done,configured,built}
+ 	rm -f $$($(2)_DIR)/.stamp_{target,staging}_installed
++	$$(call $(2)_FIXUP_DOT_CONFIG)
+ 
+ # Target to copy back the configuration to the source configuration file
+ $(1)-update-config: $$($(2)_DIR)/.stamp_kconfig_fixup_done
+-- 
+2.1.0
+
diff --git a/lab-data/buildroot/buildroot-rootfs/buildroot/0004-core-pkg-kconfig-allow-saving-config-to-a-non-existi.patch b/lab-data/buildroot/buildroot-rootfs/buildroot/0004-core-pkg-kconfig-allow-saving-config-to-a-non-existi.patch
new file mode 100644
index 0000000..495f509
--- /dev/null
+++ b/lab-data/buildroot/buildroot-rootfs/buildroot/0004-core-pkg-kconfig-allow-saving-config-to-a-non-existi.patch
@@ -0,0 +1,90 @@
+From 47fde9fb42c51cd652b9a8b2ae010f4b674b77ed Mon Sep 17 00:00:00 2001
+From: "Yann E. MORIN" <yann.morin.1998 at free.fr>
+Date: Sat, 13 Jun 2015 18:46:37 +0200
+Subject: [PATCH] core/pkg-kconfig: allow saving config to a non-existing
+ custom config file
+
+A very interesting use-case for a kconfig-based package is to create a
+custom (def)config file based on one bundled with the package itself,
+like described in PR-8156:
+
+    make menuconfig
+     -> enable kernel, use an in-tree defconfig, save and exit
+    make linux-menuconfig
+     -> enable/disable whatever option, save and exit
+    make menuconfig
+     -> change to use a custom defconfig file, set a path, save and exit
+    make linux-update-config
+     -> should save to the new custom defconfig file
+
+However, that is currently not possible, because the dependency chain
+when saving the configuration goes back up to the (newly-set!) custom
+(def)config file, which does not exist.
+
+So, we break the dependency chain so that saving the configuration does
+not depend on that file. Instead, we use a terminal rule that checks
+that the configuration has indeed been done, and fails if not.
+
+Closes #8156.
+
+Reported-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
+Signed-off-by: "Yann E. MORIN" <yann.morin.1998 at free.fr>
+Cc: Thomas De Schampheleire <patrickdepinguin at gmail.com>
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
+---
+ package/pkg-kconfig.mk | 31 +++++++++++++++++++++++++++----
+ 1 file changed, 27 insertions(+), 4 deletions(-)
+
+diff --git a/package/pkg-kconfig.mk b/package/pkg-kconfig.mk
+index fceff51..a19e7f9 100644
+--- a/package/pkg-kconfig.mk
++++ b/package/pkg-kconfig.mk
+@@ -83,9 +83,10 @@ $$($(2)_TARGET_CONFIGURE): $$($(2)_DIR)/.stamp_kconfig_fixup_done
+ 
+ # Configuration editors (menuconfig, ...)
+ #
+-# Apply the kconfig fixups right after exiting the configurators, so
+-# that the user always sees a .config file that is clean wrt. our
+-# requirements.
++# We need to apply the configuration fixups right after a configuration
++# editor exits, so that it is possible to save the configuration right
++# after exiting an editor, and so the user always sees a .config file
++# that is clean wrt. our requirements.
+ #
+ # Because commands in $(1)_FIXUP_KCONFIG are probably using $(@D), we
+ # fake it for the configurators (otherwise it is set to just '.', i.e.
+@@ -101,8 +102,30 @@ $$(addprefix $(1)-,$$($(2)_KCONFIG_EDITORS)): $$($(2)_DIR)/.stamp_kconfig_fixup_
+ 	rm -f $$($(2)_DIR)/.stamp_{target,staging}_installed
+ 	$$(call $(2)_FIXUP_DOT_CONFIG)
+ 
++# Saving back the configuration
++#
++# Ideally, that should directly depend on $$($(2)_DIR)/.stamp_kconfig_fixup_done,
++# but that breaks the use-case in PR-8156 (from a clean tree):
++#   make menuconfig           <- enable kernel, use an in-tree defconfig, save and exit
++#   make linux-menuconfig     <- enable/disable whatever option, save and exit
++#   make menuconfig           <- change to use a custom defconfig file, set a path, save and exit
++#   make linux-update-config  <- should save to the new custom defconfig file
++#
++# Because of that use-case, saving the configuration can *not* directly
++# depend on the stamp file, because it itself depends on the .config,
++# which in turn depends on the (newly-set an non-existent) custom
++# defconfig file.
++#
++# Instead, we use an PHONY rule that will catch that situation.
++#
++$(1)-check-configuration-done:
++	@if [ ! -f $$($(2)_DIR)/.stamp_kconfig_fixup_done ]; then \
++		echo "$(1) is not yet configured"; \
++		exit 1; \
++	fi
++
+ # Target to copy back the configuration to the source configuration file
+-$(1)-update-config: $$($(2)_DIR)/.stamp_kconfig_fixup_done
++$(1)-update-config: $(1)-check-configuration-done
+ 	cp --preserve=timestamps -f $$($(2)_DIR)/.config $$($(2)_KCONFIG_FILE)
+ 
+ endef # inner-kconfig-package
+-- 
+2.1.0
+
diff --git a/lab-data/buildroot/buildroot-rootfs/0001-Add-nunchuk-driver.patch b/lab-data/buildroot/buildroot-rootfs/linux/0001-Add-nunchuk-driver.patch
similarity index 100%
rename from lab-data/buildroot/buildroot-rootfs/0001-Add-nunchuk-driver.patch
rename to lab-data/buildroot/buildroot-rootfs/linux/0001-Add-nunchuk-driver.patch
diff --git a/lab-data/buildroot/buildroot-rootfs/0002-Add-i2c1-and-nunchuk-nodes-in-dts.patch b/lab-data/buildroot/buildroot-rootfs/linux/0002-Add-i2c1-and-nunchuk-nodes-in-dts.patch
similarity index 100%
rename from lab-data/buildroot/buildroot-rootfs/0002-Add-i2c1-and-nunchuk-nodes-in-dts.patch
rename to lab-data/buildroot/buildroot-rootfs/linux/0002-Add-i2c1-and-nunchuk-nodes-in-dts.patch



More information about the training-materials-updates mailing list