* [PATCH] defaultenv: Reorder overlay append order
@ 2014-09-10 14:46 Teresa Gámez
2014-09-11 7:24 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Teresa Gámez @ 2014-09-10 14:46 UTC (permalink / raw)
To: barebox
The defaultenv_add_base() functions adds the enviroment coming from
CONFIG_DEFAULT_ENVIRONMENT_PATH. But this is not only for
traditional enviroments, but also for external enviroments in e.g. build
systems. The external enviroment should override the enviroment set
in the board file and not the other way around. Made sure that
external enviroment is always added last.
Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
---
defaultenv/defaultenv.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/defaultenv/defaultenv.c b/defaultenv/defaultenv.c
index dc0e484..3b4efcf 100644
--- a/defaultenv/defaultenv.c
+++ b/defaultenv/defaultenv.c
@@ -50,10 +50,20 @@ static void defaultenv_add_base(void)
defaultenv_append_directory(defaultenv_2_dfu);
if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC))
defaultenv_append_directory(defaultenv_1);
+}
+
+static void defaultenv_add_external(void)
+{
+ static int external_added;
+
+ if (external_added)
+ return;
+
+ external_added = 1;
/*
- * The traditional environment given with CONFIG_DEFAULT_ENVIRONMENT_PATH.
- * Once all users are converted to bbenv-y this can go.
+ * The traditional or external environment given with
+ * CONFIG_DEFAULT_ENVIRONMENT_PATH.
*/
defaultenv_append((void *)default_environment,
default_environment_size, "defaultenv");
@@ -141,6 +151,8 @@ int defaultenv_load(const char *dir, unsigned flags)
defaultenv_add_base();
+ defaultenv_add_external();
+
list_for_each_entry(df, &defaultenv_list, list) {
ret = defaultenv_load_one(df, dir, flags);
if (ret)
--
1.7.0.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] defaultenv: Reorder overlay append order
2014-09-10 14:46 [PATCH] defaultenv: Reorder overlay append order Teresa Gámez
@ 2014-09-11 7:24 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2014-09-11 7:24 UTC (permalink / raw)
To: Teresa Gámez; +Cc: barebox
Hi Teresa,
On Wed, Sep 10, 2014 at 04:46:08PM +0200, Teresa Gámez wrote:
> The defaultenv_add_base() functions adds the enviroment coming from
> CONFIG_DEFAULT_ENVIRONMENT_PATH. But this is not only for
> traditional enviroments, but also for external enviroments in e.g. build
> systems. The external enviroment should override the enviroment set
> in the board file and not the other way around. Made sure that
> external enviroment is always added last.
>
> Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
So what happens is:
At some point board code calls defaultenv_append() which calls
defaultenv_add_base() which in turn registers all default env snippets
including the one from CONFIG_DEFAULT_ENVIRONMENT_PATH. After this
defaultenv_append adds the snippet passed to it.
Instead you want CONFIG_DEFAULT_ENVIRONMENT_PATH to be the last instance
and register it right before using the default environment in
defaultenv_load().
I had some trouble understanding what was wrong and how you solved
it, the above is mainly for me. I hope I find it the next time I stumble
upon this ;)
Something tells me this is not the last time I think about this piece
of code.
Ok, applied.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-11 7:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-10 14:46 [PATCH] defaultenv: Reorder overlay append order Teresa Gámez
2014-09-11 7:24 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox