mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
android-commands.sh: Reformat file with shftm
This commit is contained in:
parent
78ce521c01
commit
037aaf0a36
1 changed files with 38 additions and 18 deletions
|
@ -14,12 +14,11 @@
|
||||||
# success, some other number for errors (an empty file is basically the same as
|
# success, some other number for errors (an empty file is basically the same as
|
||||||
# 0). Note that the return codes are text, not raw bytes.
|
# 0). Note that the return codes are text, not raw bytes.
|
||||||
|
|
||||||
|
|
||||||
this_repo="$(dirname $(dirname -- "$(readlink -- "${0}")"))"
|
this_repo="$(dirname $(dirname -- "$(readlink -- "${0}")"))"
|
||||||
|
|
||||||
help () {
|
help() {
|
||||||
echo \
|
echo \
|
||||||
"Usage: $0 COMMAND [ARG]
|
"Usage: $0 COMMAND [ARG]
|
||||||
|
|
||||||
where COMMAND is one of:
|
where COMMAND is one of:
|
||||||
snapshot APK install APK and dependencies on an emulator to prep a snapshot
|
snapshot APK install APK and dependencies on an emulator to prep a snapshot
|
||||||
|
@ -43,7 +42,7 @@ hit_enter() {
|
||||||
|
|
||||||
launch_termux() {
|
launch_termux() {
|
||||||
echo "launching termux"
|
echo "launching termux"
|
||||||
if ! adb shell 'am start -n com.termux/.HomeActivity' ; then
|
if ! adb shell 'am start -n com.termux/.HomeActivity'; then
|
||||||
echo "failed to launch termux"
|
echo "failed to launch termux"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -62,14 +61,17 @@ run_termux_command() {
|
||||||
probe="$2" # unique file that indicates the command is complete
|
probe="$2" # unique file that indicates the command is complete
|
||||||
launch_termux
|
launch_termux
|
||||||
adb shell input text "$command" && hit_enter
|
adb shell input text "$command" && hit_enter
|
||||||
while ! adb shell "ls $probe" 2>/dev/null; do echo "waiting for $probe"; sleep 30; done
|
while ! adb shell "ls $probe" 2>/dev/null; do
|
||||||
|
echo "waiting for $probe"
|
||||||
|
sleep 30
|
||||||
|
done
|
||||||
return_code=$(adb shell "cat $probe")
|
return_code=$(adb shell "cat $probe")
|
||||||
adb shell "rm $probe"
|
adb shell "rm $probe"
|
||||||
echo "return code: $return_code"
|
echo "return code: $return_code"
|
||||||
return $return_code
|
return $return_code
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshot () {
|
snapshot() {
|
||||||
apk="$1"
|
apk="$1"
|
||||||
echo "running snapshot"
|
echo "running snapshot"
|
||||||
adb install -g "$apk"
|
adb install -g "$apk"
|
||||||
|
@ -121,7 +123,7 @@ snapshot () {
|
||||||
adb shell input text "exit" && hit_enter && hit_enter
|
adb shell input text "exit" && hit_enter && hit_enter
|
||||||
}
|
}
|
||||||
|
|
||||||
sync () {
|
sync() {
|
||||||
repo="$1"
|
repo="$1"
|
||||||
echo "running sync $1"
|
echo "running sync $1"
|
||||||
# android doesn't allow symlinks on shared dirs, and adb can't selectively push files
|
# android doesn't allow symlinks on shared dirs, and adb can't selectively push files
|
||||||
|
@ -148,7 +150,7 @@ sync () {
|
||||||
run_termux_command "$command" "$probe"
|
run_termux_command "$command" "$probe"
|
||||||
}
|
}
|
||||||
|
|
||||||
build () {
|
build() {
|
||||||
probe='/sdcard/build.probe'
|
probe='/sdcard/build.probe'
|
||||||
command="'cd ~/coreutils && cargo build --features feat_os_unix_android 2>/sdcard/build.log; echo \$? >$probe'"
|
command="'cd ~/coreutils && cargo build --features feat_os_unix_android 2>/sdcard/build.log; echo \$? >$probe'"
|
||||||
echo "running build"
|
echo "running build"
|
||||||
|
@ -159,7 +161,7 @@ build () {
|
||||||
return $return_code
|
return $return_code
|
||||||
}
|
}
|
||||||
|
|
||||||
tests () {
|
tests() {
|
||||||
probe='/sdcard/tests.probe'
|
probe='/sdcard/tests.probe'
|
||||||
command="'\
|
command="'\
|
||||||
export PATH=\$HOME/.cargo/bin:\$PATH; \
|
export PATH=\$HOME/.cargo/bin:\$PATH; \
|
||||||
|
@ -182,16 +184,34 @@ exit_code=0
|
||||||
|
|
||||||
if [ $# -eq 1 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
case "$1" in
|
case "$1" in
|
||||||
sync) sync "$this_repo"; exit_code=$?;;
|
sync)
|
||||||
build) build; exit_code=$?;;
|
sync "$this_repo"
|
||||||
tests) tests; exit_code=$?;;
|
exit_code=$?
|
||||||
*) help;;
|
;;
|
||||||
|
build)
|
||||||
|
build
|
||||||
|
exit_code=$?
|
||||||
|
;;
|
||||||
|
tests)
|
||||||
|
tests
|
||||||
|
exit_code=$?
|
||||||
|
;;
|
||||||
|
*) help ;;
|
||||||
esac
|
esac
|
||||||
elif [ $# -eq 2 ]; then
|
elif [ $# -eq 2 ]; then
|
||||||
case "$1" in
|
case "$1" in
|
||||||
snapshot) snapshot "$2"; exit_code=$?;;
|
snapshot)
|
||||||
sync) sync "$2"; exit_code=$?;;
|
snapshot "$2"
|
||||||
*) help; exit 1;;
|
exit_code=$?
|
||||||
|
;;
|
||||||
|
sync)
|
||||||
|
sync "$2"
|
||||||
|
exit_code=$?
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
help
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
help
|
help
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue