~qaul/community

clients/android: don't override USER in build.sh v1 PROPOSED

Alyssa Ross
Alyssa Ross: 2
 clients/android: don't override USER in build.sh
 clients/android: fix build.sh undefined variable

 2 files changed, 7 insertions(+), 7 deletions(-)
Hey there,
Next
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~qaul/community/patches/10861/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH 1/2] clients/android: don't override USER in build.sh Export this patch

Alyssa Ross
USER is a standard global environment variable that contains the name
of the current user.  Previously, build.sh would reassign user to be
the id of the current user.  This would break podman, which uses $USER
to find the name of the user to look up in /etc/subuid.

Since environment variables are conventionally upper case, using
lowercase variable names in scripts avoids the problem of overriding
variables in the environment.
---
 clients/android/build.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/clients/android/build.sh b/clients/android/build.sh
index 44cba421..eb559798 100755
--- a/clients/android/build.sh
+++ b/clients/android/build.sh
@@ -2,18 +2,18 @@

set -e

BASEDIR=$(realpath $(dirname "$0"))
USER=$(id -u)
GROUP=$(id -g)
basedir=$(realpath $(dirname "$0"))
user=$(id -u)
group=$(id -g)

if [ $1 = "dev" ]; then
    echo "Attaching shell for repeated builds."
    echo "Don't invoke gradle yourself! Use 'client/android/.build_nested.sh' instead!"
    echo "Don't forget to run 'export USER=$USER GROUP=$GROUP'!"
    docker run --rm -it -v $BASEDIR/../../:/qaul.net qaulnet/android-build-env /bin/bash
    docker run --rm -it -v $basedir/../../:/qaul.net qaulnet/android-build-env /bin/bash
  
else
    echo "Running one-shot-build"
    docker run --rm -it -v $BASEDIR/../../:/qaul.net qaulnet/android-build-env \
           /qaul.net/clients/android/.build_nested.sh $USER $GROUP
    docker run --rm -it -v $basedir/../../:/qaul.net qaulnet/android-build-env \
           /qaul.net/clients/android/.build_nested.sh $user $group
fi
-- 
2.26.2

[PATCH 2/2] clients/android: fix build.sh undefined variable Export this patch

Alyssa Ross
If no argument was given, this script would produce the error:

    ./build.sh: line 9: [: =: unary operator expected

This happened because the expansion of the [ command became

    [ = "dev" ]

Adding the quotes around $1 makes the expansion

    [ "" = "dev" ]

Which is what we actually want.
---
 clients/android/build.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clients/android/build.sh b/clients/android/build.sh
index eb559798..b644bef0 100755
--- a/clients/android/build.sh
+++ b/clients/android/build.sh
@@ -6,7 +6,7 @@ basedir=$(realpath $(dirname "$0"))
user=$(id -u)
group=$(id -g)

if [ $1 = "dev" ]; then
if [ "$1" = "dev" ]; then
    echo "Attaching shell for repeated builds."
    echo "Don't invoke gradle yourself! Use 'client/android/.build_nested.sh' instead!"
    echo "Don't forget to run 'export USER=$USER GROUP=$GROUP'!"
-- 
2.26.2