chore(brew): Automatically install gcc if not present

This commit is contained in:
fiftydinar 2024-06-04 16:27:50 +02:00
parent d2273f410a
commit 1786a30e5e
2 changed files with 12 additions and 6 deletions

View file

@ -16,6 +16,7 @@ The brew module installs [Homebrew / Linuxbrew](https://brew.sh/) on your system
### Build-time:
- Necessary Brew package dependency `gcc` is installed if not present in the base image
- Directories `/home/` & `/root/` are created
- Empty `.dockerenv` file is created in the root of the image-builder, to convince official Brew installation script that we are **not** running as root
- Official brew installation script is downloaded & executed

View file

@ -2,22 +2,24 @@
set -euo pipefail
# Convince the installer that we are in CI
touch /.dockerenv
# Debugging
DEBUG="${DEBUG:-false}"
if [[ "${DEBUG}" == true ]]; then
set -x
fi
# Check if gcc is installed
if ! command -v gcc &> /dev/null
then
# Check if gcc is installed & install it if it's not
# (add VanillaOS package manager in the future when it gets supported)
if ! command -v gcc &> /dev/null; then
if command -v rpm-ostree &> /dev/null; then
echo "Installing \"gcc\" package, which is necessary for Brew to function."
rpm-ostree install gcc
else
echo "ERROR: \"gcc\" package could not be found."
echo " Brew depends on \"gcc\" in order to function"
echo " Please include \"gcc\" in the list of packages to install with the system package manager"
exit 1
fi
fi
# Module-specific directories and paths
@ -68,6 +70,9 @@ fi
mkdir -p /var/home
mkdir -p /var/roothome
# Convince the installer that we are in CI
touch /.dockerenv
# Always install Brew
echo "Downloading and installing Brew..."
curl -Lo /tmp/brew-install https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh