Attempt to fix when Sdk/ already exists but latest/sdkmanager is not present yet.

This commit is contained in:
Hyperling 2025-02-26 08:29:31 -07:00
parent d0d5a5306b
commit 2708e367df

View File

@ -12,28 +12,41 @@
# Command-line tools is all Flutter actually needs: # Command-line tools is all Flutter actually needs:
# https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip # https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
- name: Workstation | Linux | Software | Android | Facts [1/2] - name: Workstation | Linux | Software | Android | Facts [1/3]
set_fact: set_fact:
android_url: "https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip" android_url: "https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip"
android_download_file: "{{ user_user.home }}/Downloads/android-cmdline-tools.tar.xz" android_download_file: "{{ user_user.home }}/Downloads/android-cmdline-tools.tar.xz"
android_sdk_location: "{{ user_user.home }}/SDKs/Android/Sdk" android_sdk_location: "{{ user_user.home }}/SDKs/Android/Sdk"
- name: Workstation | Linux | Software | Android | Facts [2/2] - name: Workstation | Linux | Software | Android | Facts [2/3]
set_fact: set_fact:
android_bin_location: "{{ android_sdk_location }}/platform-tools" android_bin_location: "{{ android_sdk_location }}/platform-tools"
android_sdkmanager: "{{ android_sdk_location }}/cmdline-tools/bin/sdkmanager" android_sdk_location_temp: "{{ android_sdk_location }}/ansible"
android_sdkmanager_final: "{{ android_sdk_location }}/cmdline-tools/latest/bin/sdkmanager"
- name: Workstation | Linux | Software | Android | Facts [3/3]
set_fact:
android_sdkmanager_temp: "{{ android_sdk_location_temp }}/cmdline-tools/bin/sdkmanager"
## Checks ## ## Checks ##
- name: Workstation | Linux | Software | Android | Check SDK Exists - name: Workstation | Linux | Software | Android | Check SDK Manager Exists [1/2]
stat: stat:
path: "{{ android_bin_location }}" path: "{{ android_sdkmanager_temp }}"
register: android_sdk_stat register: android_sdkmanager_temp_stat
when: coding == true
- name: Workstation | Linux | Software | Android | Check SDK Manager Exists [2/2]
stat:
path: "{{ android_sdkmanager_final }}"
register: android_sdkmanage_final_stat
when: coding == true
- name: Workstation | Linux | Software | Android | Check Download Exists - name: Workstation | Linux | Software | Android | Check Download Exists
stat: stat:
path: "{{ android_download_file }}" path: "{{ android_download_file }}"
register: android_download_stat register: android_download_stat
when: coding == true
## Packages ## ## Packages ##
@ -86,7 +99,7 @@
owner: "{{ user }}" owner: "{{ user }}"
group: "{{ user }}" group: "{{ user }}"
when: coding == true and not android_sdk_stat.stat.exists when: coding == true and not android_sdkmanager_temp_stat.stat.exists
- name: Workstation | Linux | Software | Android | Delete Archive - name: Workstation | Linux | Software | Android | Delete Archive
file: file:
@ -95,13 +108,21 @@
## Configure Modules ## ## Configure Modules ##
- name: Workstation | Linux | Software | Android | Install Modules # This can only be run once, otherwise cmdline-tools creates latest-* folders.
shell: "yes | {{ android_sdkmanager }} '{{ item }}' --sdk_root={{ android_sdk_location }}" - name: Workstation | Linux | Software | Android | Install Consistent Modules
shell: "yes | {{ android_sdkmanager_temp }} --install '{{ item }}' --sdk_root={{ android_sdk_location }}"
loop: loop:
# latest # Current
- cmdline-tools;latest - cmdline-tools;latest
- platform-tools - platform-tools
- emulator - emulator
become_user: "{{ user }}"
when: coding == true and not android_sdkmanager_final_stat.stat.exists
# These are safe to run multiple times.
- name: Workstation | Linux | Software | Android | Install Modules
shell: "yes | {{ android_sdkmanager_final }} --install '{{ item }}' --sdk_root={{ android_sdk_location }}"
loop:
# 34 # 34
- build-tools;34.0.0 - build-tools;34.0.0
- platforms;android-34 - platforms;android-34
@ -112,22 +133,31 @@
- platforms;android-35 - platforms;android-35
- sources;android-35 - sources;android-35
# Images # Images
- system-images;android-35;default;x86_64 #- system-images;android-35;default;x86_64
- system-images;android-35;aosp_atd;x86_64 #- system-images;android-35;aosp_atd;x86_64
- system-images;android-35;google_apis_playstore;x86_64 - system-images;android-35;google_apis_playstore;x86_64
become_user: "{{ user }}" become_user: "{{ user }}"
when: coding == true and not android_sdkmanager_final_stat.stat.exists
- name: Workstation | Linux | Software | Android | Update Modules - name: Workstation | Linux | Software | Android | Update Modules
shell: "yes | {{ android_sdkmanager }} --update --sdk_root={{ android_sdk_location }}" shell: "yes | {{ android_sdkmanager_final }} --update --sdk_root={{ android_sdk_location }}"
become_user: "{{ user }}" become_user: "{{ user }}"
when: coding == true
- name: Workstation | Linux | Software | Android | Inform Flutter - name: Workstation | Linux | Software | Android | Inform Flutter
shell: "{{ flutter }} config --android-sdk={{ android_sdk_location }}" shell: "{{ flutter }} config --android-sdk={{ android_sdk_location }}"
become_user: "{{ user }}" become_user: "{{ user }}"
when: coding == true
- name: Workstation | Linux | Software | Android | License Agreements - name: Workstation | Linux | Software | Android | Licenses Agreements [1/2]
shell: "yes | {{ android_sdkmanager_final }} --licenses --android-sdk={{ android_sdk_location }}"
become_user: "{{ user }}"
when: coding == true
- name: Workstation | Linux | Software | Android | License Agreements [2/2]
shell: "yes | {{ flutter }} doctor --android-licenses" shell: "yes | {{ flutter }} doctor --android-licenses"
become_user: "{{ user }}" become_user: "{{ user }}"
when: coding == true
- name: Workstation | Linux | Software | Android | Refresh Flutter Doctor Report - name: Workstation | Linux | Software | Android | Refresh Flutter Doctor Report
shell: "{{ item }}" shell: "{{ item }}"
@ -141,7 +171,7 @@
blockinfile: blockinfile:
path: "{{ item }}/.bashrc" path: "{{ item }}/.bashrc"
block: | block: |
export PATH="$PATH:{{ android_bin_location }}" export PATH="$PATH:{{ android_bin_location }}:{{ android_sdkmanager_final }}"
marker: '# {mark} MANAGED BY ANSIBLE | Android' marker: '# {mark} MANAGED BY ANSIBLE | Android'
state: present state: present
create: yes create: yes
@ -156,7 +186,7 @@
blockinfile: blockinfile:
path: "{{ item }}/.zshrc" path: "{{ item }}/.zshrc"
block: | block: |
export PATH="$PATH:{{ android_bin_location }}" export PATH="$PATH:{{ android_bin_location }}:{{ android_sdkmanager_final }}"
marker: '# {mark} MANAGED BY ANSIBLE | Android' marker: '# {mark} MANAGED BY ANSIBLE | Android'
state: present state: present
create: yes create: yes