-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
android-gadget-setup: fix conditional argument to assign serial variable #553
Conversation
...recipes-devtools/android-tools/android-tools-conf-configfs/qcom/android-gadget-setup.machine
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit message is pretty hard to follow. Also [ -n ]
is not a syntax error, otherwise sh would have complained.
6da7f30
to
24009a5
Compare
Updated the commit message to make it more readable. I added the logs in the PR to elaborate the issue faced. |
It still talks about the syntax error. |
I’ll try this and get back! |
Also, I'm not sure how does that fix the issue for the serial number being not available in the |
if serial number is not available in |
Ok, so we should be back to #547 to get the proper serial number even if we fix this script. |
c17187a
to
7626f20
Compare
Followed this. Can you check? |
There is still a talk about the syntax error in the commit message. Also could you please check whether a single |
set 1$ cat file1
set -e
val="someval"
if [ -r ./file2 ] ; then
. ./file2
fi
echo $val $ cat file2
a=""
[ -n "$a" ] && val="$a"
exit 0 $ sh -x ./file1
+ set -e
+ val=someval
+ '[' -r ./file2 ']'
+ . ./file2
++ a=
++ '[' -n '' ']'
++ exit 0 set 2$ cat file2
a=""
[ -n "$a" ] && val="$a" || true $ sh -x ./file1
+ set -e
+ val=someval
+ '[' -r ./file2 ']'
+ . ./file2
++ a=
++ '[' -n '' ']'
++ true
+ echo someval
someval |
My mistake. Updated the commit message. |
set 3$ cat file2
a="newval"
[ -n "$a" ] && val="$a" || true $ sh -x ./file1
+ set -e
+ val=someval
+ '[' -r ./file2 ']'
+ . ./file2
++ a=newval
++ '[' -n newval ']'
++ val=newval
+ echo newval
newval |
This is still not applicable to the source code in question. There is a string argument after [ -n "$androidserial" ] |
Ack, I checked, this works: lumag@eriador:/tmp$ cat test.sh
#!/bin/sh
set -e
if [ -r test2.sh ] ; then
. ./test2.sh
fi
echo continued
lumag@eriador:/tmp$ cat test2.sh
[ -n "$EMPTY" ] && echo not-empty
true
lumag@eriador:/tmp$ sh test.sh
continued
lumag@eriador:/tmp$ EMPTY=not sh test.sh
not-empty
continued |
yeah |
Yes, please. |
And fix the commit message too. |
Change the conditional argument to check if androidserial is non-empty. The condition `[ -n ]` when `androidserial` is empty is equated to `false` which results in an non-zero status from `android-gadget-setup.machine`. /usr/bin/android-gadget-setup starts with `set -e` is used to change behavior of the shell in various ways. `-e` option causes the shell to exit as soon a command exits with a non-zero status. Hence, executing `true` in the end results in a zero exit status in all cases, which suffices the condition for `set -e`, hence unblocking android-tools-adbd service when `androidserial` is not defined. Signed-off-by: Chirag Jain <[email protected]>
fixed the code as well as the commit message. Thanks @lumag ! |
@lumag so is it complete or anything else needed? |
Change the conditional argument to check if androidserial is non-empty.
Initially we observed the following logs on boot-up as well as on running
systemctl restart android-tools-adbd
Boot-up logs:
Logs of
systemctl restart android-tools-adbd
To analyze any issue in the script, we ran
$ sh -x /usr/bin/android-gadget-setup
, and got the followingScript abruptly stopped at
'[' -n ]
, which is a syntax error. Script is running underset -e
so any non-zero exit code in a command will abort the script. To fix the issue, we made the patch as provided in the commit.After the patch, we saw the following output of
$ sh -x /usr/bin/android-gadget-setup
We can see that the script progressed past the stage of
[ -n ]
, confirming that the patch works. Further,android-tools-adbd
started working and we could see the device visible inadb devices
on host machine.