Files
code-tools/tf/scripts/dev-tools.sh
2025-09-19 18:37:42 +00:00

45 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
if command -v apt-get >/dev/null 2>&1; then
wait_for_apt() {
if command -v fuser >/dev/null 2>&1; then
while \
fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1 ||
fuser /var/lib/apt/lists/lock >/dev/null 2>&1 ||
fuser /var/lib/dpkg/lock >/dev/null 2>&1; do
echo "Waiting for apt locks to clear..."
sleep 2
done
else
# Fallback when fuser is unavailable
sleep 2
fi
}
apt_exec() {
if command -v sudo >/dev/null 2>&1; then
sudo "$@"
else
"$@"
fi
}
export DEBIAN_FRONTEND=noninteractive
wait_for_apt
apt_exec apt-get update -qq
wait_for_apt
apt_exec apt-get install -y \
make tree jq curl wget unzip git ripgrep fd-find htop >/dev/null
# fd binary name differs on Debian
if [[ ! -e /usr/local/bin/fd && -e /usr/bin/fdfind ]]; then
apt_exec ln -sf /usr/bin/fdfind /usr/local/bin/fd
fi
fi
if command -v npm >/dev/null 2>&1; then
npm install -g tldr fkill-cli >/dev/null 2>&1 || true
fi
echo "Development tooling refreshed."