Skip to content
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

unixPb: Add role to install intel homebrew for arm64 macs #3185

Merged
merged 11 commits into from
Nov 6, 2023
3 changes: 3 additions & 0 deletions ansible/playbooks/AdoptOpenJDK_Unix_Playbook/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
- role: Xcode
when: ansible_distribution == "MacOSX"
tags: [build_tools, xcode, adoptopenjdk]
- role: Homebrew_intel
when: ansible_distribution == "MacOSX" and ansible_architecture == "arm64"
tags: [build_tools, homebrew_intel]
- role: cmake # OpenJ9 / OpenJFX
when: ansible_distribution != "Solaris" # Compile fails on Solaris
tags: [build_tools, build_tools_openj9, build_tools_openjfx]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

- name: Set homebrew path (x64)
set_fact:
homebrew_path: /usr/local/bin/brew
homebrew_path: /usr/local/bin
karianna marked this conversation as resolved.
Show resolved Hide resolved
when: ansible_architecture == "x86_64"

- name: Set homebrew path (Arm64)
set_fact:
homebrew_path: /opt/homebrew/bin/brew
homebrew_path: /opt/homebrew/bin
when: ansible_architecture == "arm64"

- name: Configure system-wide Bash profile
Expand Down Expand Up @@ -67,7 +67,7 @@

- name: Check if Homebrew is already installed
stat:
path: "{{ homebrew_path }}"
path: "{{ homebrew_path }}/brew"
register: brew

- name: Install Homebrew
Expand All @@ -81,6 +81,7 @@
become_user: "{{ ansible_user }}"
homebrew:
upgrade_all: yes
path: "{{ homebrew_path }}"
when: "macos_version_number is version('10.15', '>')"
tags:
- brew_upgrade
Expand All @@ -90,6 +91,7 @@
become_user: "{{ ansible_user }}"
homebrew_tap:
name: buo/cask-upgrade
path: "{{ homebrew_path }}"
tags:
- brew_cu

Expand All @@ -98,27 +100,34 @@
become_user: "{{ ansible_user }}"
homebrew_tap:
name: AdoptOpenJDK/openjdk
path: "{{ homebrew_path }}"

# Skipping linting as no situation where this can't run (lint error 301)
- name: Update Casks
become: yes
become_user: "{{ ansible_user }}"
command: "{{ homebrew_path }} cu -y"
command: "{{ homebrew_path }}/brew cu -y"
tags:
- brew_cu
- skip_ansible_lint

- name: Install Build Tool Packages
become: yes
become_user: "{{ ansible_user }}"
homebrew: "name={{ item }} state=present"
homebrew:
name: "{{ item }}"
state: present
path: "{{ homebrew_path }}"
with_items: "{{ Build_Tool_Packages }}"
tags: build_tools

- name: Install Build Tool Packages NOT macOS 10.12
become: yes
become_user: "{{ ansible_user }}"
homebrew: "name={{ item }} state=present"
homebrew:
name: "{{ item }}"
state: present
path: "{{ homebrew_path }}"
with_items: "{{ Build_Tool_Packages_NOT_10_12 }}"
when:
- not (macos_version_number | regex_search("10.12"))
Expand All @@ -127,21 +136,30 @@
- name: Install Build Tool Casks
become: yes
become_user: "{{ ansible_user }}"
homebrew_cask: "name={{ item }} state=present"
homebrew_cask:
name: "{{ item }}"
state: present
path: "{{ homebrew_path }}"
with_items: "{{ Build_Tool_Casks }}"
tags: build_tools

- name: Install Test Tool Packages
become: yes
become_user: "{{ ansible_user }}"
homebrew: "name={{ item }} state=present"
homebrew:
name: "{{ item }}"
state: present
path: "{{ homebrew_path }}"
with_items: "{{ Test_Tool_Packages }}"
tags: test_tools

- name: Install JCK Tool Casks
become: yes
become_user: "{{ ansible_user }}"
homebrew_cask: "name={{ item }} state=present"
homebrew_cask:
name: "{{ item }}"
state: present
path: "{{ homebrew_path }}"
with_items: "{{ JCK_Tool_Casks }}"
tags: jck_tools

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
# Install Intel Homebrew onto our arm64 mac machines. This is needed to build x64 jdk8
# The freetype build process requires Intel libpng installed, which needs Intel Homebrew
# See https://github.com/adoptium/infrastructure/issues/2536#issuecomment-1708716478

- name: Check if Intel Homebrew is installed
stat:
path: /usr/local/Homebrew/bin/brew
register: intel_homebrew_installed

- name: Run Homebrew install script in a Rosetta shell
ansible.builtin.shell: yes | arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
when: not intel_homebrew_installed.stat.exists

- name: Install Intel libpng
ansible.builtin.shell: arch -x86_64 yes | /usr/local/Homebrew/bin/brew install libpng
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is presumably the bit that caused the problems from #3231 so I'm going to block this change on the basis that we presumably fix this PR before it goes live.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,22 @@
########################################
# Install Nagios dependencies packages #
########################################

- name: Set Mac homebrew path (x64)
set_fact:
homebrew_path: /usr/local/bin
when: ansible_architecture == "x86_64"

- name: Set Mac homebrew path (Arm64)
set_fact:
homebrew_path: /opt/homebrew/bin
when: ansible_architecture == "arm64"

- name: Install additional packages used by Nagios
homebrew: "name={{ item }} state=present"
homebrew:
name: "{{ item }}"
state: present
path: "{{ homebrew_path }}"
become: yes
become_user: "{{ ansible_user }}"
with_items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
Ensure that Apple_ID_User, Apple_ID_Password and FASTLANE_SESSION are defined. Skipping Xcode installation"
when: apple_variables is not defined

- name: Set Mac homebrew path (x64)
set_fact:
homebrew_path: /usr/local/bin
when: ansible_architecture == "x86_64"

- name: Set Mac homebrew path (Arm64)
set_fact:
homebrew_path: /opt/homebrew/bin
when: ansible_architecture == "arm64"

- name: Install Xcode
when: apple_variables is defined
block:
Expand All @@ -29,6 +39,7 @@
homebrew:
name: [email protected] # no 3.0 yet for fastlane (https://github.com/fastlane/fastlane/issues/17931)
state: present
path: "{{ homebrew_path }}"

- name: Configure Bash profile extension for Ruby
become: yes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
curl_latest: 7.79.1
tags: curl

- name: Set Mac homebrew path (x64)
set_fact:
homebrew_path: /usr/local/bin
when: ansible_distribution == "MacOSX" and ansible_architecture == "x86_64"

- name: Set Mac homebrew path (Arm64)
set_fact:
homebrew_path: /opt/homebrew/bin
when: ansible_distribution == "MacOSX" and ansible_architecture == "arm64"

- name: Download curl {{ curl_latest }}
get_url:
url: https://github.com/curl/curl/releases/download/curl-7_79_1/curl-{{ curl_latest }}.tar.gz
Expand Down Expand Up @@ -114,6 +124,7 @@
homebrew:
name: curl
state: latest
path: "{{ homebrew_path }}"
when:
- ansible_distribution == "MacOSX"
- "macos_version_number is version('10.13', '>')"
Expand Down
Loading