Fix package install logic

This commit is contained in:
TheSpad 2022-09-06 09:44:57 +01:00
parent 12eda7a831
commit fe11b1ded7
No known key found for this signature in database
GPG key ID: 08F06191F4587860

View file

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