2020-10-07 13:49:40 +05:00
|
|
|
#!/bin/bash -e
|
2020-04-10 14:20:16 +05:00
|
|
|
################################################################################
|
|
|
|
|
## File: homebrew.sh
|
|
|
|
|
## Desc: Installs the Homebrew on Linux
|
2020-07-07 08:05:14 +03:00
|
|
|
## Caveat: Brew MUST NOT be used to install any tool during the image build to avoid dependencies, which may come along with the tool
|
2020-04-10 14:20:16 +05:00
|
|
|
################################################################################
|
|
|
|
|
|
|
|
|
|
# Source the helpers
|
|
|
|
|
source $HELPER_SCRIPTS/etc-environment.sh
|
2021-04-14 19:34:49 +03:00
|
|
|
source $HELPER_SCRIPTS/install.sh
|
2020-04-10 14:20:16 +05:00
|
|
|
|
|
|
|
|
# Install the Homebrew on Linux
|
|
|
|
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
2021-08-18 11:57:22 +03:00
|
|
|
brew_shellenv="/home/linuxbrew/.linuxbrew/bin/brew shellenv"
|
2020-04-10 14:20:16 +05:00
|
|
|
|
2021-08-18 11:57:22 +03:00
|
|
|
# Update /etc/environment
|
|
|
|
|
## Put HOMEBREW_* variables.
|
2021-08-30 11:55:56 +03:00
|
|
|
$brew_shellenv | grep 'export HOMEBREW' | sed -E 's/^export (.*);$/\1/' | tr -d '"' | sudo tee -a /etc/environment
|
2020-04-10 14:20:16 +05:00
|
|
|
# add brew executables locations to PATH
|
2021-08-18 11:57:22 +03:00
|
|
|
brew_path=$($brew_shellenv | grep '^export PATH' | sed -E 's/^export PATH="([^$]+)\$.*/\1/')
|
2020-07-07 08:05:14 +03:00
|
|
|
prependEtcEnvironmentPath "$brew_path"
|
2021-01-21 13:21:32 +05:00
|
|
|
setEtcEnvironmentVariable HOMEBREW_NO_AUTO_UPDATE 1
|
|
|
|
|
setEtcEnvironmentVariable HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS 3650
|
2020-04-10 14:20:16 +05:00
|
|
|
|
|
|
|
|
# Validate the installation ad hoc
|
|
|
|
|
echo "Validate the installation reloading /etc/environment"
|
|
|
|
|
reloadEtcEnvironment
|
|
|
|
|
|
2021-04-14 19:34:49 +03:00
|
|
|
# Install additional brew packages
|
|
|
|
|
brew_packages=$(get_toolset_value .brew[].name)
|
|
|
|
|
for package in $brew_packages; do
|
|
|
|
|
echo "Install $package"
|
|
|
|
|
brew install $package
|
|
|
|
|
# create symlinks for zstd in /usr/local/bin
|
|
|
|
|
if [[ $package == "zstd" ]]; then
|
|
|
|
|
find $(brew --prefix)/bin -name *zstd* -exec sudo sh -c 'ln -s {} /usr/local/bin/$(basename {})' ';'
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
2020-12-25 18:03:35 +03:00
|
|
|
invoke_tests "Tools" "Homebrew"
|