public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] scripts/get_default_envs.sh: preserve order of multiple entries for same variable
@ 2020-01-06 12:01 Rasmus Villemoes
  2020-01-06 12:16 ` Lukasz Majewski
  2020-05-07 13:03 ` Tom Rini
  0 siblings, 2 replies; 5+ messages in thread
From: Rasmus Villemoes @ 2020-01-06 12:01 UTC (permalink / raw)
  To: u-boot

It's possible that the default_environment[] array contains multiple
entries for the same variable, e.g. a setting from env_default.h based
on some CONFIG_* variable, and another from
CONFIG_EXTRA_ENV_SETTINGS. In such a case, the last setting takes
effect.

Hence, in order to be able to use the output from this script as an
CONFIG_DEFAULT_ENV_FILE and get the same default environment as one
currently has, we need to preserve the order. So only sort by the
variable name, and disable the last-resort comparison.

We could pipe the result through uniq to remove duplicate lines, but I
think there's some value in seeing that certain variables are defined
multiple times.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 scripts/get_default_envs.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/get_default_envs.sh b/scripts/get_default_envs.sh
index da86a9d69c..d1f2ce4d5c 100755
--- a/scripts/get_default_envs.sh
+++ b/scripts/get_default_envs.sh
@@ -35,7 +35,7 @@ cp ${env_obj_file_path} ${ENV_OBJ_FILE_COPY}
 ${OBJCOPY} -O binary -j ".rodata.default_environment" ${ENV_OBJ_FILE_COPY}
 
 # Replace default '\0' with '\n' and sort entries
-tr '\0' '\n' < ${ENV_OBJ_FILE_COPY} | sort -u
+tr '\0' '\n' < ${ENV_OBJ_FILE_COPY} | sort --field-separator== -k1,1 --stable
 
 rm ${ENV_OBJ_FILE_COPY}
 
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] scripts/get_default_envs.sh: preserve order of multiple entries for same variable
  2020-01-06 12:01 [PATCH] scripts/get_default_envs.sh: preserve order of multiple entries for same variable Rasmus Villemoes
@ 2020-01-06 12:16 ` Lukasz Majewski
  2020-01-30  2:17   ` Simon Glass
  2020-05-07 13:03 ` Tom Rini
  1 sibling, 1 reply; 5+ messages in thread
From: Lukasz Majewski @ 2020-01-06 12:16 UTC (permalink / raw)
  To: u-boot

Hi Rasmus,

> It's possible that the default_environment[] array contains multiple
> entries for the same variable, e.g. a setting from env_default.h based
> on some CONFIG_* variable, and another from
> CONFIG_EXTRA_ENV_SETTINGS. In such a case, the last setting takes
> effect.
> 
> Hence, in order to be able to use the output from this script as an
> CONFIG_DEFAULT_ENV_FILE and get the same default environment as one
> currently has, we need to preserve the order. So only sort by the
> variable name, and disable the last-resort comparison.
> 
> We could pipe the result through uniq to remove duplicate lines, but I
> think there's some value in seeing that certain variables are defined
> multiple times.
> 
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> ---
>  scripts/get_default_envs.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/get_default_envs.sh b/scripts/get_default_envs.sh
> index da86a9d69c..d1f2ce4d5c 100755
> --- a/scripts/get_default_envs.sh
> +++ b/scripts/get_default_envs.sh
> @@ -35,7 +35,7 @@ cp ${env_obj_file_path} ${ENV_OBJ_FILE_COPY}
>  ${OBJCOPY} -O binary -j ".rodata.default_environment"
> ${ENV_OBJ_FILE_COPY} 
>  # Replace default '\0' with '\n' and sort entries
> -tr '\0' '\n' < ${ENV_OBJ_FILE_COPY} | sort -u
> +tr '\0' '\n' < ${ENV_OBJ_FILE_COPY} | sort --field-separator== -k1,1
> --stable 
>  rm ${ENV_OBJ_FILE_COPY}
>  

Reviewed-by: Lukasz Majewski <lukma@denx.de>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200106/8cb426c3/attachment.sig>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] scripts/get_default_envs.sh: preserve order of multiple entries for same variable
  2020-01-06 12:16 ` Lukasz Majewski
@ 2020-01-30  2:17   ` Simon Glass
  2020-04-29  8:46     ` Rasmus Villemoes
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Glass @ 2020-01-30  2:17 UTC (permalink / raw)
  To: u-boot

On Mon, 6 Jan 2020 at 05:17, Lukasz Majewski <lukma@denx.de> wrote:
>
> Hi Rasmus,
>
> > It's possible that the default_environment[] array contains multiple
> > entries for the same variable, e.g. a setting from env_default.h based
> > on some CONFIG_* variable, and another from
> > CONFIG_EXTRA_ENV_SETTINGS. In such a case, the last setting takes
> > effect.
> >
> > Hence, in order to be able to use the output from this script as an
> > CONFIG_DEFAULT_ENV_FILE and get the same default environment as one
> > currently has, we need to preserve the order. So only sort by the
> > variable name, and disable the last-resort comparison.
> >
> > We could pipe the result through uniq to remove duplicate lines, but I
> > think there's some value in seeing that certain variables are defined
> > multiple times.
> >
> > Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> > ---
> >  scripts/get_default_envs.sh | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] scripts/get_default_envs.sh: preserve order of multiple entries for same variable
  2020-01-30  2:17   ` Simon Glass
@ 2020-04-29  8:46     ` Rasmus Villemoes
  0 siblings, 0 replies; 5+ messages in thread
From: Rasmus Villemoes @ 2020-04-29  8:46 UTC (permalink / raw)
  To: u-boot

On 30/01/2020 03.17, Simon Glass wrote:
> On Mon, 6 Jan 2020 at 05:17, Lukasz Majewski <lukma@denx.de> wrote:
>>
>> Hi Rasmus,
>>
>>> It's possible that the default_environment[] array contains multiple
>>> entries for the same variable, e.g. a setting from env_default.h based
>>> on some CONFIG_* variable, and another from
>>> CONFIG_EXTRA_ENV_SETTINGS. In such a case, the last setting takes
>>> effect.
>>>
>>> Hence, in order to be able to use the output from this script as an
>>> CONFIG_DEFAULT_ENV_FILE and get the same default environment as one
>>> currently has, we need to preserve the order. So only sort by the
>>> variable name, and disable the last-resort comparison.
>>>
>>> We could pipe the result through uniq to remove duplicate lines, but I
>>> think there's some value in seeing that certain variables are defined
>>> multiple times.
>>>
>>> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
>>> ---
>>>  scripts/get_default_envs.sh | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> Reviewed-by: Lukasz Majewski <lukma@denx.de>
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 

Hi Tom,

This has two R-Bs, perhaps I can get you to pick it up?

Thanks,
Rasmus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] scripts/get_default_envs.sh: preserve order of multiple entries for same variable
  2020-01-06 12:01 [PATCH] scripts/get_default_envs.sh: preserve order of multiple entries for same variable Rasmus Villemoes
  2020-01-06 12:16 ` Lukasz Majewski
@ 2020-05-07 13:03 ` Tom Rini
  1 sibling, 0 replies; 5+ messages in thread
From: Tom Rini @ 2020-05-07 13:03 UTC (permalink / raw)
  To: u-boot

On Mon, Jan 06, 2020 at 12:01:17PM +0000, Rasmus Villemoes wrote:

> It's possible that the default_environment[] array contains multiple
> entries for the same variable, e.g. a setting from env_default.h based
> on some CONFIG_* variable, and another from
> CONFIG_EXTRA_ENV_SETTINGS. In such a case, the last setting takes
> effect.
> 
> Hence, in order to be able to use the output from this script as an
> CONFIG_DEFAULT_ENV_FILE and get the same default environment as one
> currently has, we need to preserve the order. So only sort by the
> variable name, and disable the last-resort comparison.
> 
> We could pipe the result through uniq to remove duplicate lines, but I
> think there's some value in seeing that certain variables are defined
> multiple times.
> 
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> Reviewed-by: Lukasz Majewski <lukma@denx.de>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200507/0d24d5d6/attachment.sig>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-05-07 13:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-06 12:01 [PATCH] scripts/get_default_envs.sh: preserve order of multiple entries for same variable Rasmus Villemoes
2020-01-06 12:16 ` Lukasz Majewski
2020-01-30  2:17   ` Simon Glass
2020-04-29  8:46     ` Rasmus Villemoes
2020-05-07 13:03 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox