Fix package install logic

This commit is contained in:
TheSpad 2022-09-06 09:45:47 +01:00
parent 9b539b59ab
commit eab3b6ba11
No known key found for this signature in database
GPG key ID: 08F06191F4587860

View file

@ -2,33 +2,44 @@
# shellcheck shell=bash # shellcheck shell=bash
if [[ -f "/mod-repo-packages-to-install.list" ]]; then if [[ -f "/mod-repo-packages-to-install.list" ]]; then
echo "**** Installing all mod packages ****" IFS=' ' read -ra REPO_PACKAGES <<< "$(cat /mod-repo-packages-to-install.list)"
if [[ -f /usr/bin/apt ]]; then if [[ ${#REPO_PACKAGES[@]} -ne 0 ]] && [[ ${REPO_PACKAGES[*]} != "" ]]; then
export DEBIAN_FRONTEND="noninteractive" echo "**** Installing all mod packages ****"
apt-get update if [[ -f /usr/bin/apt ]]; then
apt-get install -y --no-install-recommends \ export DEBIAN_FRONTEND="noninteractive"
$(cat /mod-repo-packages-to-install.list) apt-get update
elif [[ -f /sbin/apk ]]; then apt-get install -y --no-install-recommends \
apk add --no-cache \ "${REPO_PACKAGES[@]}"
$(cat /mod-repo-packages-to-install.list) elif [[ -f /sbin/apk ]]; then
apk add --no-cache \
"${REPO_PACKAGES[@]}"
elif [ -f /usr/bin/dnf ]; then
dnf install -y --setopt=install_weak_deps=False --best \
"${REPO_PACKAGES[@]}"
fi
fi fi
fi fi
if [[ -f "/mod-pip-packages-to-install.list" ]]; then if [[ -f "/mod-pip-packages-to-install.list" ]]; then
echo "**** Installing all pip packages ****" IFS=' ' read -ra PIP_PACKAGES <<< "$(cat /mod-pip-packages-to-install.list)"
python3 -m pip install -U pip wheel setuptools if [[ ${#PIP_PACKAGES[@]} -ne 0 ]] && [[ ${PIP_PACKAGES[*]} != "" ]]; then
if [[ -f /usr/bin/apt ]]; then echo "**** Installing all pip packages ****"
PIP_ARGS="-f https://wheel-index.linuxserver.io/ubuntu/" python3 -m pip install -U pip wheel setuptools
elif [[ -f /sbin/apk ]]; then PIP_ARGS=()
ALPINE_VER=$(grep main /etc/apk/repositories | sed 's|.*alpine/v||' | sed 's|/main.*||') if [[ -f /usr/bin/apt ]]; then
if [[ "${ALPINE_VER}" = "3.14" ]]; then PIP_ARGS+=("-f" "https://wheel-index.linuxserver.io/ubuntu/")
PIP_ARGS="-f https://wheel-index.linuxserver.io/alpine/" elif [[ -f /sbin/apk ]]; then
else ALPINE_VER=$(grep main /etc/apk/repositories | sed 's|.*alpine/v||' | sed 's|/main.*||')
PIP_ARGS="-f https://wheel-index.linuxserver.io/alpine-${ALPINE_VER}/" if [[ "${ALPINE_VER}" = "3.14" ]]; then
PIP_ARGS+=("-f" "https://wheel-index.linuxserver.io/alpine/")
else
PIP_ARGS+=("-f" "https://wheel-index.linuxserver.io/alpine-${ALPINE_VER}/")
fi
fi fi
python3 -m pip install \
"${PIP_ARGS[@]}" \
"${PIP_PACKAGES[@]}"
fi fi
python3 -m pip install ${PIP_ARGS} \
$(cat /mod-pip-packages-to-install.list)
fi fi
rm -rf \ rm -rf \