Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _skip_if_exists:
_tasks:
- uv sync --all-extras
- uv venv
- source .venv/bin/activate
- . .venv/bin/activate
- uv run nox -s setup

project_icon:
Expand Down
129 changes: 71 additions & 58 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,45 @@

echo "Installing dev tools to enable project management with oe-python-template and derivatives ..."

LINUX_APT_TOOLS=(
"curl;curl;https://curl.se/"
)

BREW_TOOLS=(
"uv;uv;https://docs.astral.sh/uv/"
"git;git;https://git-scm.com/"
"gpg;gnupg;https://gnupg.org/"
"gmake;make;https://www.gnu.org/software/make/"
"jq;jq;https://jqlang.org/"
"xmllint;libxml2;https://en.wikipedia.org/wiki/Libxml2"
"act;act;https://nektosact.com/"
"pinact;pinact;https://github.com/suzuki-shunsuke/pinact"
"trivy;trivy;https://trivy.dev/latest/"
"pnpm;pnpm;https://pnpm.io/"
"magick;imagemagick;https://imagemagick.org/"
"nixpacks;nixpacks;https://nixpacks.com/"
)

MAC_BREW_TOOLS=(
"pinentry-mac;pinentry-mac;https://github.com/GPGTools/pinentry"
)

LINUX_BREW_TOOLS=(
# Linux-specific Homebrew tools will be added here
)

UV_TOOLS=(
"copier;copier;https://copier.readthedocs.io/"
)
# Define tool lists as strings with delimiters for cross-platform compatibility
LINUX_APT_TOOLS="curl;curl;https://curl.se/"

BREW_TOOLS="uv;uv;https://docs.astral.sh/uv/
git;git;https://git-scm.com/
gpg;gnupg;https://gnupg.org/
gmake;make;https://www.gnu.org/software/make/
jq;jq;https://jqlang.org/
xmllint;libxml2;https://en.wikipedia.org/wiki/Libxml2
act;act;https://nektosact.com/
pinact;pinact;https://github.com/suzuki-shunsuke/pinact
trivy;trivy;https://trivy.dev/latest/
pnpm;pnpm;https://pnpm.io/
magick;imagemagick;https://imagemagick.org/
nixpacks;nixpacks;https://nixpacks.com/"

MAC_BREW_TOOLS="pinentry-mac;pinentry-mac;https://github.com/GPGTools/pinentry"

LINUX_BREW_TOOLS=""

UV_TOOLS="copier;copier;https://copier.readthedocs.io/"

# Function to install/update brew tools
install_or_upgrade_brew_tool() {
local tool=$1
local package=$2
local url=$3

if command -v "$tool" &> /dev/null; then
if command -v "$tool" > /dev/null 2>&1; then
tool_path=$(command -v "$tool")
if [[ "$tool_path" == *"brew/"* ]]; then
echo "$tool already installed via Homebrew at $tool_path, upgrading..."
brew upgrade "$package" || true
else
echo "$tool already installed at $tool_path, skipping..."
fi
case "$tool_path" in
*brew/*)
echo "$tool already installed via Homebrew at $tool_path, upgrading..."
brew upgrade "$package" || true
;;
*)
echo "$tool already installed at $tool_path, skipping..."
;;
esac
else
echo "Installing $tool from $package... # $url"
brew install "$package"
Expand All @@ -60,7 +54,7 @@ install_or_update_linux_apt_tool() {
local package=$2
local url=$3

if command -v "$tool" &> /dev/null; then
if command -v "$tool" > /dev/null 2>&1; then
echo "$tool already installed at $(command -v "$tool"), skipping..."
else
echo "Installing $tool... # $url"
Expand All @@ -73,7 +67,7 @@ install_or_update_uv_tool() {
local tool=$1
local url=$3

if command -v "$tool" &> /dev/null; then
if command -v "$tool" > /dev/null 2>&1; then
echo "$tool already installed at $(command -v "$tool"), updating..."
uv tool update "$tool"
else
Expand All @@ -83,46 +77,65 @@ install_or_update_uv_tool() {
}

# Install/update Linux packages
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
for tool_entry in "${LINUX_APT_TOOLS[@]}"; do
IFS=";" read -r tool package url <<< "$tool_entry"
install_or_update_linux_apt_tool "$tool" "$package" "$url"
if [ "$(uname -s | cut -c1-5)" = "Linux" ]; then
echo "$LINUX_APT_TOOLS" | while IFS=';' read -r tool package url; do
[ -n "$tool" ] && install_or_update_linux_apt_tool "$tool" "$package" "$url"
done
fi

# Install/update Homebrew itself
if ! command -v brew &> /dev/null; then
if ! command -v brew > /dev/null 2>&1; then
echo "Installing Homebrew... # https://brew.sh/"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Add Homebrew to PATH based on platform
if [ "$(uname -s)" = "Darwin" ]; then
# macOS - Homebrew path setup
if [ "$(uname -m)" = "arm64" ]; then
# M1/M2 Mac
eval "$(/opt/homebrew/bin/brew shellenv)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$HOME/.zprofile"
else
# Intel Mac
eval "$(/usr/local/bin/brew shellenv)"
echo 'eval "$(/usr/local/bin/brew shellenv)"' >> "$HOME/.zprofile"
fi
elif [ "$(uname -s | cut -c1-5)" = "Linux" ]; then
# Linux - Homebrew path setup
if [ -d "$HOME/.linuxbrew" ]; then
eval "$($HOME/.linuxbrew/bin/brew shellenv)"
fi
if [ -d "/home/linuxbrew/.linuxbrew" ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
brew_prefix=$(brew --prefix 2>/dev/null || echo "/home/linuxbrew/.linuxbrew")
echo "eval \$(${brew_prefix}/bin/brew shellenv)" >> "$HOME/.bashrc"
fi
else
echo "Homebrew already installed at $(command -v brew), updating..."
brew update
fi

# Install/update Homebrew tools
for tool_entry in "${BREW_TOOLS[@]}"; do
IFS=";" read -r tool package url <<< "$tool_entry"
install_or_upgrade_brew_tool "$tool" "$package" "$url"
echo "$BREW_TOOLS" | while IFS=';' read -r tool package url; do
[ -n "$tool" ] && install_or_upgrade_brew_tool "$tool" "$package" "$url"
done

# Install/update Homebrew tools for macOS
if [[ "$OSTYPE" == "darwin"* ]]; then
for tool_entry in "${MAC_BREW_TOOLS[@]}"; do
IFS=";" read -r tool package url <<< "$tool_entry"
install_or_upgrade_brew_tool "$tool" "$package" "$url"
if [ "$(uname -s)" = "Darwin" ]; then
echo "$MAC_BREW_TOOLS" | while IFS=';' read -r tool package url; do
[ -n "$tool" ] && install_or_upgrade_brew_tool "$tool" "$package" "$url"
done
fi

# Install/update Homebrew tools for Linux
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
for tool_entry in "${LINUX_BREW_TOOLS[@]}"; do
IFS=";" read -r tool package url <<< "$tool_entry"
install_or_upgrade_brew_tool "$tool" "$package" "$url"
if [ "$(uname -s | cut -c1-5)" = "Linux" ]; then
echo "$LINUX_BREW_TOOLS" | while IFS=';' read -r tool package url; do
[ -n "$tool" ] && install_or_upgrade_brew_tool "$tool" "$package" "$url"
done
fi

# Install/update UV tools
for tool_entry in "${UV_TOOLS[@]}"; do
IFS=";" read -r tool package url <<< "$tool_entry"
install_or_update_uv_tool "$tool" "$url"
echo "$UV_TOOLS" | while IFS=';' read -r tool package url; do
[ -n "$tool" ] && install_or_update_uv_tool "$tool" "$url"
done