:-'Generic Commit'

This commit is contained in:
Your Name 2025-05-29 21:11:27 +12:00
parent 1d0b1f79b3
commit 503a366400

View File

@ -53,10 +53,13 @@ print_warning() {
# Function to check if a package is installed # Function to check if a package is installed
function is_package_installed() { is_package_installed() {
dpkg -l "$1" 2>/dev/null | grep -q "^ii" if [ "$OS" = "Alpine Linux" ]; then
apk info | grep -q "^$1$"
else
dpkg -l "$1" 2>/dev/null | grep -q "^ii"
fi
} }
function install_packages() { function install_packages() {
local PACKAGES local PACKAGES
local HAVE_UPDATED=0 local HAVE_UPDATED=0
@ -77,7 +80,14 @@ function install_packages() {
case $OS in case $OS in
"Ubuntu"|"Debian GNU/Linux") "Ubuntu"|"Debian GNU/Linux")
# Common packages for both Ubuntu and Debian # Common packages for both Ubuntu and Debian
PACKAGES="nlohmann-json3-dev wget curl cmake ninja-build mold build-essential" PACKAGES="bash build-essential cmake git wget tar curl ninja-build mold nodejs npm"
INSTALLCMD="apt-get install -y"
UPDATECMD="apt-get update"
;;
"Alpine Linux")
PACKAGES="bash build-base cmake git wget tar curl ninja mold nodejs npm"
INSTALLCMD="apk add --no-cache"
UPDATECMD="apk update"
;; ;;
*) *)
print_error "Unsupported distribution: $OS" print_error "Unsupported distribution: $OS"
@ -94,11 +104,11 @@ function install_packages() {
# Update package lists # Update package lists
if [ "$HAVE_UPDATED" -eq 0 ]; then if [ "$HAVE_UPDATED" -eq 0 ]; then
print_status "Updating package lists..." print_status "Updating package lists..."
apt-get update ${SUDOCMD:-} "${UPDATECMD}"
HAVE_UPDATED=1 HAVE_UPDATED=1
fi fi
if ! "$SUDOCMD" apt-get install -y "$pkg"; then if ! ${SUDOCMD:-} "${INSTALLCMD}" "$pkg"; then
print_error "Failed to install $pkg" print_error "Failed to install $pkg"
exit 1 exit 1
fi fi