From 31d06d6e48e7d2553fffeb973e4a4423daf8ca11 Mon Sep 17 00:00:00 2001 From: Oliver Spryn <2717340+oliverspryn@users.noreply.github.com> Date: Wed, 11 Mar 2020 11:00:45 -0400 Subject: [PATCH] Change license acceptance approach --- README.md | 1 - config.sh | 12 ------------ emulator/create-avd.sh | 8 ++++++-- host/create-paths.sh | 8 ++++---- host/install-android-sdk.sh | 10 +++++++--- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 97a03db..d29ecb4 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,6 @@ The `config.sh` file is the central point for configuring the behavior of the pi | `commandLineToolsDownloadUrlPattern` | Regex pattern used to extract the latest Command Line Tools from the Android Studio download page. | String | :x: | | `emulatorBootedSleepTime` | How long to wait, in seconds, after the emulator's boot has finished to ensure the launcher is visible and ready for user interaction. | Integer | :x: | | `jdkPattern` | Regex pattern used to identify the latest JDK 8 build available from SDKMan. | String | :x: | -| `sdkManagerWaitTime` | How long to wait, in seconds, as commands to the `sdkmanager` are made. Useful for automatically accepting any licenses without hanging the process. | Integer | :x: | | `startEmulatorTimeout` | How long to wait, in seconds, before assuming the Android Emulator will not or did not properly start. | Integer | :x: | Feel free to open the `setup-emulator.sh` and `setup-host.sh` files to see each of the steps which run, and enable or disable them according to your needs. diff --git a/config.sh b/config.sh index a7c3675..3f54498 100755 --- a/config.sh +++ b/config.sh @@ -76,18 +76,6 @@ emulatorBootedSleepTime=30 # from SDKMan. More info on versions here: https://bit.ly/2SCGEnb jdkPattern="8\.0\.[0-9][0-9][0-9]\.hs\-adpt" -# How long to wait, in seconds for the SDKManager to complete an -# operation. This number also indicates how many times to send a -# "y" to the manager, in case it asks for end-user license -# acceptance. Adjust based on your experiments/requirements. -# -# Please note that your builds will be longer, since each -# SDKManager operations will take at least these many seconds. It -# does, however, prove itself to be very reliable in a hands- -# off scenario to handle all of the SDK's prompts. So, keep that -# in mind as you adjust this number. -sdkManagerWaitTime=90 - # How long to wait, in seconds, before timing out and assuming # that the emulator will not start. Adjust based on your # experiments/requirements. diff --git a/emulator/create-avd.sh b/emulator/create-avd.sh index dd63585..2e22843 100755 --- a/emulator/create-avd.sh +++ b/emulator/create-avd.sh @@ -20,14 +20,18 @@ else imageName="system-images;android-$androidSdkVersion;google_apis;x86" fi +(for run in {1..1000}; do echo y; done) >> yep.txt + echo "Obtaining image: $imageName" -(for run in {1..$sdkManagerWaitTime}; do sleep 1; echo y 2>/dev/null; done) | sdkmanager $imageName >> /dev/null +cat ./yep.txt | sdkmanager $imageName >> /dev/null echo "Obtained" echo "Accepting any remaining licenses" -(for run in {1..$sdkManagerWaitTime}; do sleep 1; echo y 2>/dev/null; done) | sdkmanager --licenses +cat ./yep.txt | sdkmanager --licenses echo "All licenses accepted" +rm ./yep.txt + # Create the AVD echo "Creating AVD: $emulatorDeviceName" diff --git a/host/create-paths.sh b/host/create-paths.sh index 9bce1ec..5a7e31c 100755 --- a/host/create-paths.sh +++ b/host/create-paths.sh @@ -10,13 +10,13 @@ echo "===========================" echo # Create the file -echo "export ANDROID_HOME=$installDestination/cmdline-tools/latest/" >> "$currentDir/paths.sh" +echo "export ANDROID_HOME=$installDestination" >> "$currentDir/paths.sh" echo -n 'PATH=$PATH:' >> "$currentDir/paths.sh" -echo "$installDestination/cmdline-tools/latest/bin/" >> "$currentDir/paths.sh" +echo "$installDestination/cmdline-tools/latest/bin" >> "$currentDir/paths.sh" echo -n 'PATH=$PATH:' >> "$currentDir/paths.sh" -echo "$installDestination/emulator/" >> "$currentDir/paths.sh" +echo "$installDestination/emulator" >> "$currentDir/paths.sh" echo -n 'PATH=$PATH:' >> "$currentDir/paths.sh" -echo "$installDestination/platform-tools/" >> "$currentDir/paths.sh" +echo "$installDestination/platform-tools" >> "$currentDir/paths.sh" echo "File created" cat "$currentDir/paths.sh" diff --git a/host/install-android-sdk.sh b/host/install-android-sdk.sh index 71ecd68..b387d86 100755 --- a/host/install-android-sdk.sh +++ b/host/install-android-sdk.sh @@ -14,14 +14,18 @@ mkdir -p "$HOME/.android" touch "$HOME/.android/repositories.cfg" # Install the SDKs +(for run in {1..1000}; do echo y; done) >> yep.txt + echo "SDKManager license" -(for run in {1..$sdkManagerWaitTime}; do sleep 1; echo y 2>/dev/null; done) | sdkmanager --update +cat ./yep.txt | sdkmanager --update echo "License accepted" echo "Obtaining the platform tools and API $androidSdkVersion tools" -(for run in {1..$sdkManagerWaitTime}; do sleep 1; echo y 2>/dev/null; done) | sdkmanager "platform-tools" "platforms;android-$androidSdkVersion" >> /dev/null +cat ./yep.txt | sdkmanager "platform-tools" "platforms;android-$androidSdkVersion" >> /dev/null echo "Finished obtaining tools" echo "Accepting any remaining licenses" -(for run in {1..$sdkManagerWaitTime}; do sleep 1; echo y 2>/dev/null; done) | sdkmanager --licenses || { status=$?; echo "Done"; } +cat ./yep.txt | sdkmanager --licenses echo "All licenses accepted" + +rm ./yep.txt