This commit is contained in:
parent
f7294e01e4
commit
483ee4e3ef
@ -46,7 +46,14 @@ print_status "Detected OS: $OS $VER"
|
|||||||
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="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"
|
print_error "Unsupported distribution: $OS"
|
||||||
@ -56,19 +63,27 @@ esac
|
|||||||
|
|
||||||
# Function to check if a package is installed
|
# Function to check if a package is installed
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update package lists
|
UPDATED=false
|
||||||
print_status "Updating package lists..."
|
|
||||||
apt-get update
|
|
||||||
|
|
||||||
# Install missing packages
|
# Install missing packages
|
||||||
print_status "Checking and installing required packages..."
|
print_status "Checking and installing required packages..."
|
||||||
for pkg in $PACKAGES; do
|
for pkg in $PACKAGES; do
|
||||||
if ! is_package_installed "$pkg"; then
|
if ! is_package_installed "$pkg"; then
|
||||||
|
if [ "$UPDATED" = false ]; then
|
||||||
|
print_status "Updating package lists..."
|
||||||
|
$UPDATECMD
|
||||||
|
UPDATED=true
|
||||||
|
fi
|
||||||
|
|
||||||
print_status "Installing $pkg..."
|
print_status "Installing $pkg..."
|
||||||
apt-get install -y "$pkg"
|
$INSTALLCMD "$pkg"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
print_error "Failed to install $pkg"
|
print_error "Failed to install $pkg"
|
||||||
exit 1
|
exit 1
|
||||||
@ -84,7 +99,7 @@ done
|
|||||||
|
|
||||||
# Set install directory
|
# Set install directory
|
||||||
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
|
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
|
||||||
USER_HOME=$(eval echo ~$SUDO_USER)
|
USER_HOME=$(eval echo "~$SUDO_USER")
|
||||||
else
|
else
|
||||||
USER_HOME="$HOME"
|
USER_HOME="$HOME"
|
||||||
fi
|
fi
|
||||||
@ -99,7 +114,7 @@ function install_musl_cross() {
|
|||||||
local MUSL_CC_URL="https://musl.cc"
|
local MUSL_CC_URL="https://musl.cc"
|
||||||
if [ ! -d "$INSTALL_DIR/$TOOLCHAIN" ]; then
|
if [ ! -d "$INSTALL_DIR/$TOOLCHAIN" ]; then
|
||||||
echo "Downloading $TOOLCHAIN musl cross toolchain..."
|
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"
|
tar -C "$INSTALL_DIR" -xvf "$TMPDIR/$TOOLCHAIN.tgz"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user