buildchroot: Remove bashism when reading file content

Message ID 20210610070222.5965-1-amikan@ilbers.de
State Accepted, archived
Headers show
Series buildchroot: Remove bashism when reading file content | expand

Commit Message

Anton Mikanovich June 9, 2021, 11:02 p.m. UTC
Reading mount counter with $(<file) was not working correctly in all
the environments, so replace it with more generic POSIX way:
$(cat file)

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 meta/classes/buildchroot.bbclass | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Henning Schild June 10, 2021, 7:05 a.m. UTC | #1
That does fix the build issues in docker/CI. So i think it should be
merged because without it people using a container workflow wont be
able to use next.

regards,
Henning

Am Thu, 10 Jun 2021 10:02:22 +0300
schrieb Anton Mikanovich <amikan@ilbers.de>:

> Reading mount counter with $(<file) was not working correctly in all
> the environments, so replace it with more generic POSIX way:
> $(cat file)
> 
> Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
> ---
>  meta/classes/buildchroot.bbclass | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/classes/buildchroot.bbclass
> b/meta/classes/buildchroot.bbclass index 97d5301..806a29f 100644
> --- a/meta/classes/buildchroot.bbclass
> +++ b/meta/classes/buildchroot.bbclass
> @@ -30,7 +30,7 @@ buildchroot_do_mounts() {
>  
>          count="1"
>          if [ -f '${BUILDCHROOT_DIR}.mount' ]; then
> -            count=$(($(< '${BUILDCHROOT_DIR}.mount') + 1))
> +            count=$(($(cat '${BUILDCHROOT_DIR}.mount') + 1))
>          fi
>          echo $count > '${BUILDCHROOT_DIR}.mount'
>          if [ $count -gt 1 ]; then
> @@ -78,9 +78,10 @@ buildchroot_undo_mounts() {
>          set -e
>  
>          if [ -f '${BUILDCHROOT_DIR}.mount' ]; then
> -            count=$(($(< '${BUILDCHROOT_DIR}.mount') - 1))
> +            count=$(($(cat '${BUILDCHROOT_DIR}.mount') - 1))
>              echo $count > '${BUILDCHROOT_DIR}.mount'
>          else
> +            echo "Could not find mount counter"
>              exit 1
>          fi
>          if [ $count -gt 0 ]; then

Patch

diff --git a/meta/classes/buildchroot.bbclass b/meta/classes/buildchroot.bbclass
index 97d5301..806a29f 100644
--- a/meta/classes/buildchroot.bbclass
+++ b/meta/classes/buildchroot.bbclass
@@ -30,7 +30,7 @@  buildchroot_do_mounts() {
 
         count="1"
         if [ -f '${BUILDCHROOT_DIR}.mount' ]; then
-            count=$(($(< '${BUILDCHROOT_DIR}.mount') + 1))
+            count=$(($(cat '${BUILDCHROOT_DIR}.mount') + 1))
         fi
         echo $count > '${BUILDCHROOT_DIR}.mount'
         if [ $count -gt 1 ]; then
@@ -78,9 +78,10 @@  buildchroot_undo_mounts() {
         set -e
 
         if [ -f '${BUILDCHROOT_DIR}.mount' ]; then
-            count=$(($(< '${BUILDCHROOT_DIR}.mount') - 1))
+            count=$(($(cat '${BUILDCHROOT_DIR}.mount') - 1))
             echo $count > '${BUILDCHROOT_DIR}.mount'
         else
+            echo "Could not find mount counter"
             exit 1
         fi
         if [ $count -gt 0 ]; then