public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] Avoid line duplicates when appended from the recipes
@ 2022-02-22 13:52 Uladzimir Bely
  2022-02-22 15:59 ` Henning Schild
  2022-02-22 16:05 ` Jan Kiszka
  0 siblings, 2 replies; 4+ messages in thread
From: Uladzimir Bely @ 2022-02-22 13:52 UTC (permalink / raw)
  To: isar-users

From: WiseLord <wiselord1983@gmail.com>

Potentially, using "cat << EOF >> target_file" can kead to duplicated
lines in the target files.

This adds simple checks for skipping lines append if they already exist.

Signed-off-by: WiseLord <wiselord1983@gmail.com>
---
 meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb | 3 ++-
 meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb      | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb b/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb
index 9c0efaf1..8436dcbd 100644
--- a/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb
+++ b/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb
@@ -21,7 +21,8 @@ OPTEE_BINARIES = "tee-header_v2.stm32 tee-pageable_v2.stm32 tee-pager_v2.stm32"
 # Set version manually to PV, the tarball does not contain any hint.
 # Alternative: pull from git and add git as build dependency.
 dpkg_runbuild_prepend() {
-    cat << EOF >> ${S}/debian/rules
+    grep -q "^export TEE_IMPL_VERSION" ${S}/debian/rules ||
+        cat << EOF >> ${S}/debian/rules
 
 export TEE_IMPL_VERSION=${PV}
 EOF
diff --git a/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb b/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb
index 28e51c0d..644535e8 100644
--- a/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb
+++ b/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb
@@ -25,7 +25,8 @@ LINUX_VERSION_EXTENSION = "-isar"
 
 # For testing purposes only
 dpkg_configure_kernel_append() {
-cat << EOF | sed -i '/^override_dh_auto_build/ r /dev/stdin' ${S}/debian/rules
+    grep -q "# CONFIG_MTD is not set" ${S}/debian/rules ||
+        cat << EOF | sed -i '/^override_dh_auto_build/ r /dev/stdin' ${S}/debian/rules
 	if ! grep "# CONFIG_MTD is not set" \$(O)/.config && \\
 	   ! grep "# CONFIG_MTD_UBI is not set" \$(O)/.config; then \\
 	    grep "# CONFIG_UBIFS_FS is not set" \$(O)/.config || \\
-- 
2.20.1


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

* Re: [PATCH] Avoid line duplicates when appended from the recipes
  2022-02-22 13:52 [PATCH] Avoid line duplicates when appended from the recipes Uladzimir Bely
@ 2022-02-22 15:59 ` Henning Schild
  2022-02-22 16:05 ` Jan Kiszka
  1 sibling, 0 replies; 4+ messages in thread
From: Henning Schild @ 2022-02-22 15:59 UTC (permalink / raw)
  To: Uladzimir Bely; +Cc: isar-users

Am Tue, 22 Feb 2022 14:52:09 +0100
schrieb Uladzimir Bely <ubely@ilbers.de>:

> From: WiseLord <wiselord1983@gmail.com>
> 
> Potentially, using "cat << EOF >> target_file" can kead to duplicated
> lines in the target files.
> 
> This adds simple checks for skipping lines append if they already
> exist.
> 
> Signed-off-by: WiseLord <wiselord1983@gmail.com>
> ---
>  meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb | 3 ++-
>  meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb      | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git
> a/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb
> b/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb index
> 9c0efaf1..8436dcbd 100644 ---
> a/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb +++
> b/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb @@
> -21,7 +21,8 @@ OPTEE_BINARIES = "tee-header_v2.stm32
> tee-pageable_v2.stm32 tee-pager_v2.stm32" # Set version manually to
> PV, the tarball does not contain any hint. # Alternative: pull from
> git and add git as build dependency. dpkg_runbuild_prepend() {
> -    cat << EOF >> ${S}/debian/rules
> +    grep -q "^export TEE_IMPL_VERSION" ${S}/debian/rules ||
> +        cat << EOF >> ${S}/debian/rules

this is a single line append, i guess a simple echo instead of a "cat
<< EOF >> " would be more readable.
If you agree you could put that on top in another patch

grep -q ...
  echo -e "\nTEE_IMPL_VERSION=${PV}" >> ${S}/debian/rules

probably the "-e" and "\n" are not even needed

Henning

>  export TEE_IMPL_VERSION=${PV}
>  EOF
> diff --git a/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb
> b/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb index
> 28e51c0d..644535e8 100644 ---
> a/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb +++
> b/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb @@ -25,7
> +25,8 @@ LINUX_VERSION_EXTENSION = "-isar" 
>  # For testing purposes only
>  dpkg_configure_kernel_append() {
> -cat << EOF | sed -i '/^override_dh_auto_build/ r /dev/stdin'
> ${S}/debian/rules
> +    grep -q "# CONFIG_MTD is not set" ${S}/debian/rules ||
> +        cat << EOF | sed -i '/^override_dh_auto_build/ r /dev/stdin'
> ${S}/debian/rules if ! grep "# CONFIG_MTD is not set" \$(O)/.config
> && \\ ! grep "# CONFIG_MTD_UBI is not set" \$(O)/.config; then \\
>  	    grep "# CONFIG_UBIFS_FS is not set" \$(O)/.config || \\


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

* Re: [PATCH] Avoid line duplicates when appended from the recipes
  2022-02-22 13:52 [PATCH] Avoid line duplicates when appended from the recipes Uladzimir Bely
  2022-02-22 15:59 ` Henning Schild
@ 2022-02-22 16:05 ` Jan Kiszka
  2022-02-23  6:13   ` Uladzimir Bely
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Kiszka @ 2022-02-22 16:05 UTC (permalink / raw)
  To: Uladzimir Bely, isar-users

On 22.02.22 14:52, Uladzimir Bely wrote:
> From: WiseLord <wiselord1983@gmail.com>
> 
> Potentially, using "cat << EOF >> target_file" can kead to duplicated
> lines in the target files.
> 
> This adds simple checks for skipping lines append if they already exist.
> 
> Signed-off-by: WiseLord <wiselord1983@gmail.com>
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You likely want to use your real name again ;)

Jan

> ---
>  meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb | 3 ++-
>  meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb      | 3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb b/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb
> index 9c0efaf1..8436dcbd 100644
> --- a/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb
> +++ b/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb
> @@ -21,7 +21,8 @@ OPTEE_BINARIES = "tee-header_v2.stm32 tee-pageable_v2.stm32 tee-pager_v2.stm32"
>  # Set version manually to PV, the tarball does not contain any hint.
>  # Alternative: pull from git and add git as build dependency.
>  dpkg_runbuild_prepend() {
> -    cat << EOF >> ${S}/debian/rules
> +    grep -q "^export TEE_IMPL_VERSION" ${S}/debian/rules ||
> +        cat << EOF >> ${S}/debian/rules
>  
>  export TEE_IMPL_VERSION=${PV}
>  EOF
> diff --git a/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb b/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb
> index 28e51c0d..644535e8 100644
> --- a/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb
> +++ b/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb
> @@ -25,7 +25,8 @@ LINUX_VERSION_EXTENSION = "-isar"
>  
>  # For testing purposes only
>  dpkg_configure_kernel_append() {
> -cat << EOF | sed -i '/^override_dh_auto_build/ r /dev/stdin' ${S}/debian/rules
> +    grep -q "# CONFIG_MTD is not set" ${S}/debian/rules ||
> +        cat << EOF | sed -i '/^override_dh_auto_build/ r /dev/stdin' ${S}/debian/rules
>  	if ! grep "# CONFIG_MTD is not set" \$(O)/.config && \\
>  	   ! grep "# CONFIG_MTD_UBI is not set" \$(O)/.config; then \\
>  	    grep "# CONFIG_UBIFS_FS is not set" \$(O)/.config || \\

-- 
Siemens AG, Technology
Competence Center Embedded Linux

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

* Re: [PATCH] Avoid line duplicates when appended from the recipes
  2022-02-22 16:05 ` Jan Kiszka
@ 2022-02-23  6:13   ` Uladzimir Bely
  0 siblings, 0 replies; 4+ messages in thread
From: Uladzimir Bely @ 2022-02-23  6:13 UTC (permalink / raw)
  To: isar-users, Jan Kiszka

In the email from Tuesday, 22 February 2022 19:05:18 +03 user Jan Kiszka 
wrote:
> On 22.02.22 14:52, Uladzimir Bely wrote:
> > From: WiseLord <wiselord1983@gmail.com>
> > 
> > Potentially, using "cat << EOF >> target_file" can kead to duplicated
> > lines in the target files.
> > 
> > This adds simple checks for skipping lines append if they already exist.
> > 
> > Signed-off-by: WiseLord <wiselord1983@gmail.com>
> 
>                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> You likely want to use your real name again ;)
> 
> Jan
> 

Thanks. Fixed in new version.

I prepared a patch on a different PC with different global .gitconfig options 
and missed this moment. I googled a bit for ways to prevent such things in the 
future, and it might be interesting for someone else.

The idea is to place to the end of `~.gitconfig` something like:
``
[includeIf "gitdir:/home/Work/"]
    path = /home/Work/.gitconfig
```
In this case all git repos in `/home/Work` and subdirectories will use 
settings from local `.gitconfig` that will override global settings.

> > ---
> > 
> >  meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb | 3 ++-
> >  meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb      | 3 ++-
> >  2 files changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb
> > b/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb index
> > 9c0efaf1..8436dcbd 100644
> > --- a/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb
> > +++ b/meta-isar/recipes-bsp/optee-os/optee-os-stm32mp15x_3.11.0.bb
> > @@ -21,7 +21,8 @@ OPTEE_BINARIES = "tee-header_v2.stm32
> > tee-pageable_v2.stm32 tee-pager_v2.stm32"> 
> >  # Set version manually to PV, the tarball does not contain any hint.
> >  # Alternative: pull from git and add git as build dependency.
> >  dpkg_runbuild_prepend() {
> > 
> > -    cat << EOF >> ${S}/debian/rules
> > +    grep -q "^export TEE_IMPL_VERSION" ${S}/debian/rules ||
> > +        cat << EOF >> ${S}/debian/rules
> > 
> >  export TEE_IMPL_VERSION=${PV}
> >  EOF
> > 
> > diff --git a/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb
> > b/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb index
> > 28e51c0d..644535e8 100644
> > --- a/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb
> > +++ b/meta-isar/recipes-kernel/linux/linux-mainline_5.4.70.bb
> > @@ -25,7 +25,8 @@ LINUX_VERSION_EXTENSION = "-isar"
> > 
> >  # For testing purposes only
> >  dpkg_configure_kernel_append() {
> > 
> > -cat << EOF | sed -i '/^override_dh_auto_build/ r /dev/stdin'
> > ${S}/debian/rules +    grep -q "# CONFIG_MTD is not set"
> > ${S}/debian/rules ||
> > +        cat << EOF | sed -i '/^override_dh_auto_build/ r /dev/stdin'
> > ${S}/debian/rules> 
> >  	if ! grep "# CONFIG_MTD is not set" \$(O)/.config && \\
> >  	
> >  	   ! grep "# CONFIG_MTD_UBI is not set" \$(O)/.config; then \\
> >  	   
> >  	    grep "# CONFIG_UBIFS_FS is not set" \$(O)/.config || \\


-- 
Uladzimir Bely




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

end of thread, other threads:[~2022-02-23  6:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22 13:52 [PATCH] Avoid line duplicates when appended from the recipes Uladzimir Bely
2022-02-22 15:59 ` Henning Schild
2022-02-22 16:05 ` Jan Kiszka
2022-02-23  6:13   ` Uladzimir Bely

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