Run eas-build-pre-install only for android

Is it possible to run eas-build-pre-install only when building android?

I run the following command to use JDK 11:

“eas-build-pre-install”: “apt-get update; apt-get -y install openjdk-11-jdk-headless”

this works fine for android but fails on ios:

Script ‘eas-build-pre-install’ is present in package.json, running it…
yarn run v1.22.10
$ apt-get update; apt-get -y install openjdk-11-jdk-headless
[stderr] /bin/sh: apt-get: command not found
[stderr] /bin/sh: apt-get: command not found
[stderr] error Command failed with exit code 127.
info Visit yarn run | Yarn for documentation about this command.
yarn exited with non-zero code: 127

move that code to the bash script and call it script from the npm hook

There is a bunch of ways to to check from bash what platfom you are on

1 Like

I have created a separate .sh file with the following content:

#!/usr/bin/env bash

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
  apt-get update
  apt-get -y install openjdk-11-jdk-headless
fi

and added new eas-build-pre-install script like this:

"scripts": {
  ...
  "eas-build-pre-install": "./eas.sh"
}

But the build is failing with the following error:

Script ‘eas-build-pre-install’ is present in package.json, running it…
yarn run v1.22.10
$ ./eas.sh
[stderr] /bin/sh: ./eas.sh: Permission denied
[stderr] error Command failed with exit code 126.
info Visit yarn run | Yarn for documentation about this command.
yarn exited with non-zero code: 126

you did not make your script executable, you need to either

  • run chmod +x eas.sh
  • change hook to "eas-build-pre-install": "bash eas.sh"