From 9230ec21dde04ffc634ae1ba897166977bf08b0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Stormacq?= Date: Fri, 2 Aug 2024 14:22:03 +0200 Subject: [PATCH] smarter amplify installation --- buildspec.yaml | 3 +-- code/ci_actions/00_install_rosetta.sh | 32 +++++++++++++++++++++++++++ code/ci_actions/02_amplify.sh | 9 ++++++-- 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100755 code/ci_actions/00_install_rosetta.sh diff --git a/buildspec.yaml b/buildspec.yaml index a283bf6..149f8e5 100644 --- a/buildspec.yaml +++ b/buildspec.yaml @@ -5,8 +5,7 @@ phases: install: commands: - - softwareupdate --install-rosetta - - curl -sL https://aws-amplify.github.io/amplify-cli/install | bash && $SHELL + - code/ci_actions/00_install_rosetta.sh pre_build: commands: diff --git a/code/ci_actions/00_install_rosetta.sh b/code/ci_actions/00_install_rosetta.sh new file mode 100755 index 0000000..0be3680 --- /dev/null +++ b/code/ci_actions/00_install_rosetta.sh @@ -0,0 +1,32 @@ +# Determine the architecture of the macOS device +processorBrand=$(/usr/sbin/sysctl -n machdep.cpu.brand_string) +if [[ "${processorBrand}" = *"Apple"* ]]; then + echo "Apple Processor is present." +else + echo "Apple Processor is not present. Rosetta not required." + exit 0 +fi + +# Check if Rosetta is installed +checkRosettaStatus=$(/bin/launchctl list | /usr/bin/grep "com.apple.oahd-root-helper") +RosettaFolder="/Library/Apple/usr/share/rosetta" +if [[ -e "${RosettaFolder}" && "${checkRosettaStatus}" != "" ]]; then + echo "Rosetta Folder exists and Rosetta Service is running. Exiting..." + exit 0 +else + echo "Rosetta Folder does not exist or Rosetta service is not running. Installing Rosetta..." +fi + +# Install Rosetta +/usr/sbin/softwareupdate --install-rosetta --agree-to-license + +# Check the result of Rosetta install command +if [[ $? -eq 0 ]]; then + echo "Rosetta installed successfully." + exit 0 +else + echo "Rosetta installation failed." + exit 1 + +fi +exit 0 \ No newline at end of file diff --git a/code/ci_actions/02_amplify.sh b/code/ci_actions/02_amplify.sh index d200f88..52dc167 100755 --- a/code/ci_actions/02_amplify.sh +++ b/code/ci_actions/02_amplify.sh @@ -12,8 +12,13 @@ if [ -f $AMPLIFY_STANDALONE ]; then elif [ -f $AMPLIFY_BREW ]; then AMPLIFY_CLI=$AMPLIFY_BREW else - echo "🛑 Amplify CLI not found" - exit 1 + echo "Amplify CLI not found, installing it" + curl -sL https://aws-amplify.github.io/amplify-cli/install | bash && $SHELL + if [ -f $AMPLIFY_STANDALONE ]; then + AMPLIFY_CLI=$AMPLIFY_STANDALONE + elif + echo "🛑 Amplify CLI not found, abording" + exit 1 fi echo "Using amplify at $AMPLIFY_CLI"