This commit is contained in:
parent
f7294e01e4
commit
483ee4e3ef
@ -46,7 +46,14 @@ print_status "Detected OS: $OS $VER"
|
||||
case $OS in
|
||||
"Ubuntu"|"Debian GNU/Linux")
|
||||
# Common packages for both Ubuntu and Debian
|
||||
PACKAGES="cmake make g++ devscripts debhelper build-essential upx musl-tools wget tar ccache ninja-build"
|
||||
PACKAGES="bash cmake make g++ devscripts debhelper build-essential upx musl-tools wget tar ccache ninja-build"
|
||||
INSTALLCMD="apt-get install -y"
|
||||
UPDATECMD="apt-get update"
|
||||
;;
|
||||
"Alpine Linux")
|
||||
PACKAGES="bash build-base cmake git nlohmann-json wget tar curl ninja mold nodejs npm"
|
||||
INSTALLCMD="apk add --no-cache"
|
||||
UPDATECMD="apk update"
|
||||
;;
|
||||
*)
|
||||
print_error "Unsupported distribution: $OS"
|
||||
@ -56,19 +63,27 @@ esac
|
||||
|
||||
# Function to check if a package is 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
|
||||
}
|
||||
|
||||
# Update package lists
|
||||
print_status "Updating package lists..."
|
||||
apt-get update
|
||||
UPDATED=false
|
||||
|
||||
# Install missing packages
|
||||
print_status "Checking and installing required packages..."
|
||||
for pkg in $PACKAGES; do
|
||||
if ! is_package_installed "$pkg"; then
|
||||
if [ "$UPDATED" = false ]; then
|
||||
print_status "Updating package lists..."
|
||||
$UPDATECMD
|
||||
UPDATED=true
|
||||
fi
|
||||
|
||||
print_status "Installing $pkg..."
|
||||
apt-get install -y "$pkg"
|
||||
$INSTALLCMD "$pkg"
|
||||
if [ $? -ne 0 ]; then
|
||||
print_error "Failed to install $pkg"
|
||||
exit 1
|
||||
@ -84,7 +99,7 @@ done
|
||||
|
||||
# Set install directory
|
||||
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
|
||||
USER_HOME=$(eval echo ~$SUDO_USER)
|
||||
USER_HOME=$(eval echo "~$SUDO_USER")
|
||||
else
|
||||
USER_HOME="$HOME"
|
||||
fi
|
||||
@ -99,7 +114,7 @@ function install_musl_cross() {
|
||||
local MUSL_CC_URL="https://musl.cc"
|
||||
if [ ! -d "$INSTALL_DIR/$TOOLCHAIN" ]; then
|
||||
echo "Downloading $TOOLCHAIN musl cross toolchain..."
|
||||
wget -nc -O "$TMPDIR/$TOOLCHAIN.tgz" $MUSL_CC_URL/$TOOLCHAIN.tgz
|
||||
wget -nc -O "$TMPDIR/$TOOLCHAIN.tgz" "$MUSL_CC_URL/$TOOLCHAIN.tgz"
|
||||
tar -C "$INSTALL_DIR" -xvf "$TMPDIR/$TOOLCHAIN.tgz"
|
||||
fi
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user