ptxdist adds ".ptxdist-defaultenv" if PTXCONF_BAREBOX_EXTRA_ENV is
enabled. If barebox oldconfig/nconfig/menuconfig do not modify the
configuration the barebox config from the BSP is copied without
executing the prepare stage responsible for amending
".ptxdist-defaultenv". The same happens on interrupted *config.

Steps to reproduce:

  ptxdist targetinstall barebox
  ptxdist menuconfig barebox (without modification)
  ptxdist drop barebox.compile
  ptxdist targetinstall barebox

Now CONFIG_DEFAULT_ENVIRONMENT_PATH is missing ".ptxdist-defaultenv"
leading to an unexpected environment.

Fix this by amending ".ptxdist-defaultenv" before compiling in case it
has not been amended before.

Signed-off-by: Bastian Stender <b...@pengutronix.de>
---
 rules/barebox.make | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/rules/barebox.make b/rules/barebox.make
index bdfefe8c6..f37f2f5f2 100644
--- a/rules/barebox.make
+++ b/rules/barebox.make
@@ -89,8 +89,6 @@ ifdef PTXCONF_BAREBOX_EXTRA_ENV
                else \
                        cp "$(path)" $(BAREBOX_DIR)/.ptxdist-defaultenv/; \
                fi;)
-       @sed -i -e "s,^\(CONFIG_DEFAULT_ENVIRONMENT_PATH=.*\)\"$$,\1 
.ptxdist-defaultenv\"," \
-               $(BAREBOX_DIR)/.config
 endif
 
        @$(call touch)
@@ -101,6 +99,15 @@ endif
 
 $(STATEDIR)/barebox.compile:
        @$(call targetinfo)
+
+ifdef PTXCONF_BAREBOX_EXTRA_ENV
+       @if test -e $(BAREBOX_CONFIG) -a \
+               $(shell grep -c -e 
"^CONFIG_DEFAULT_ENVIRONMENT_PATH=.*\.ptxdist-defaultenv" 
$(BAREBOX_DIR)/.config) -eq 0; then \
+               sed -i -e "s,^\(CONFIG_DEFAULT_ENVIRONMENT_PATH=.*\)\"$$,\1 
.ptxdist-defaultenv\"," \
+                       $(BAREBOX_DIR)/.config; \
+       fi
+endif
+
        @+cd $(BAREBOX_DIR) && $(BAREBOX_PATH) $(BAREBOX_ENV) \
                $(MAKE) $(BAREBOX_MAKEVARS)
        @$(call touch)
-- 
2.11.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

Reply via email to