erplibre/script/install/install_debian_dependency.sh

216 lines
8 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
. ./env_var.sh
EL_USER=${USER}
#EL_INSTALL_WKHTMLTOPDF="True"
# apt-get qui ATTEND le verrou (jusqu'à 10 min) : sur une image cloud fraîche,
# cloud-init / unattended-upgrades tiennent souvent le verrou apt au 1er boot
# (« Could not get lock » -> échec de l'install). DPkg::Lock::Timeout patiente.
APT_GET="sudo apt-get -o DPkg::Lock::Timeout=600"
##
### WKHTMLTOPDF download links
## === Ubuntu Focal x64 === (for other distributions please replace these two links,
## in order to have correct version of wkhtmltopdf installed, for a danger note refer to
## https://github.com/odoo/odoo/wiki/Wkhtmltopdf ):
# Ubuntu 20.04
UBUNTU_VERSION=$(lsb_release -rs)
DEBIAN_VERSION=$(lsb_release -cs)
2022-12-21 02:22:39 -05:00
OS=$(lsb_release -si)
if [[ "${OS}" == "Ubuntu" ]]; then
if [ "25.10" == "${UBUNTU_VERSION}" ] || [ "25.04" == "${UBUNTU_VERSION}" ] || [ "24.04" == "${UBUNTU_VERSION}" ] || [ "24.10" == "${UBUNTU_VERSION}" ] || [ "23.10" == "${UBUNTU_VERSION}" ] || [ "23.04" == "${UBUNTU_VERSION}" ] || [ "22.10" == "${UBUNTU_VERSION}" ] || [ "22.04" == "${UBUNTU_VERSION}" ]; then
WKHTMLTOX_X64=https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.jammy_amd64.deb
elif [ "20.04" == "${UBUNTU_VERSION}" ]; then
WKHTMLTOX_X64=https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
elif [ "18.04" == "${UBUNTU_VERSION}" ]; then
WKHTMLTOX_X64=https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb
fi
elif [[ "${OS}" == "Linuxmint" ]]; then
if [ "22.3" == "${UBUNTU_VERSION}" ]; then
WKHTMLTOX_X64=https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.jammy_amd64.deb
fi
2022-12-21 02:22:39 -05:00
elif [[ "${OS}" == "Debian" ]]; then
if [ "bookworm" == "${DEBIAN_VERSION}" ]; then
WKHTMLTOX_X64=https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bookworm_amd64.deb
else
WKHTMLTOX_X64=https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.bullseye_amd64.deb
fi
2024-02-06 21:26:49 -05:00
elif [[ "${OS}" == *"Ubuntu"* ]]; then
echo "Your version of Ubuntu is not supported, only support 18.04, 20.04 and 22.04"
WKHTMLTOX_X64=https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-3/wkhtmltox_0.12.6.1-3.jammy_amd64.deb
else
2022-12-21 00:25:29 -05:00
echo "Your version of Ubuntu is not supported, only support 18.04, 20.04 and 22.04"
exit 1
fi
#--------------------------------------------------
# Mainframe 390x
#--------------------------------------------------
if [ "$(uname -m)" = "s390x" ]; then
echo "Arch s390x detected"
sudo apt install rust-all libqpdf-dev libgeos-dev libproj-dev proj-bin proj-data libgeographiclib-dev freetds-dev freetds-bin libkrb5-dev libssl-dev pkg-config build-essential npm -y
fi
#--------------------------------------------------
# Update Server
#--------------------------------------------------
echo -e "\n---- Update Server ----"
2022-12-21 00:25:29 -05:00
if [ "18.04" == "${UBUNTU_VERSION}" ]; then
# add-apt-repository can install add-apt-repository Ubuntu 18.x
${APT_GET} install software-properties-common curl -y
2022-12-21 00:25:29 -05:00
# universe package is for Ubuntu 18.x
sudo add-apt-repository universe
# libpng12-0 dependency for wkhtmltopdf
sudo add-apt-repository "deb http://mirrors.kernel.org/ubuntu/ xenial main"
${APT_GET} update
${APT_GET} upgrade -y
2022-12-21 00:25:29 -05:00
fi
#--------------------------------------------------
# Install PostgreSQL Server
#--------------------------------------------------
echo -e "\n---- Install PostgreSQL Server ----"
${APT_GET} install postgresql postgresql-contrib libpq-dev -y
2022-12-21 00:25:29 -05:00
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "apt-get install postgresql installation error."
exit 1
fi
# PostGIS : optionnel (géospatial). Le nom du paquet « postgis » n'existe pas
# sur toutes les versions (Ubuntu 24.04) -> best-effort, ne bloque pas.
${APT_GET} install postgis -y \
|| ${APT_GET} install postgresql-postgis -y \
|| echo "PostGIS non installé (optionnel)."
echo -e "\n---- Creating the ERPLibre PostgreSQL User ----"
2022-12-21 00:25:29 -05:00
sudo su - postgres -c "createuser -s ${EL_USER}" 2>/dev/null || true
#--------------------------------------------------
# Install Dependencies
#--------------------------------------------------
echo -e "\n--- Installing debian dependency --"
${APT_GET} install git build-essential wget libxslt-dev libzip-dev libldap2-dev libsasl2-dev gdebi-core libffi-dev libbz2-dev parallel pysassc swig cmake portaudio19-dev libcups2-dev shfmt xmlsec1 -y
2022-12-21 00:25:29 -05:00
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "apt-get debian tool installation error."
exit 1
fi
${APT_GET} install libmariadbd-dev freetds-dev -y
2022-12-21 00:25:29 -05:00
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "apt-get libmariadb installation error."
exit 1
fi
if [ "18.04" == "${UBUNTU_VERSION}" ]; then
${APT_GET} install libpng12-0 -y
2022-12-21 00:25:29 -05:00
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "apt-get libpng installation error."
exit 1
fi
fi
# Dependencies for pyenv
${APT_GET} install make libssl-dev zlib1g-dev libreadline-dev libsqlite3-dev curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev liblzma-dev -y
2022-12-21 00:25:29 -05:00
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "apt-get pyenv dependencies installation error."
exit 1
fi
# Dependencies for selenium
${APT_GET} install libcairo2-dev python3-dev pkg-config libxt-dev libgirepository1.0-dev -y
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "apt-get selenium dependencies installation error."
exit 1
fi
echo -e "\n---- Installing nodeJS NPM and rtlcss for LTR support ----"
${APT_GET} update
${APT_GET} install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
if [ "18.04" == "${UBUNTU_VERSION}" ]; then
sudo apt remove nodeJS npm
NODE_MAJOR=16
else
# Node 22+ required by @capacitor/cli v8.x (mobile app dependency)
NODE_MAJOR=22
2022-12-21 00:25:29 -05:00
fi
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
${APT_GET} update
${APT_GET} install nodejs -y
sudo npm install npm@latest -g
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "npm install npm lastest installation error."
exit 1
fi
sudo npm install -g rtlcss
2022-12-21 00:25:29 -05:00
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "npm install rtlcss installation error."
2022-12-21 00:25:29 -05:00
exit 1
fi
sudo npm install -g less
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "npm install less installation error."
exit 1
fi
echo -e "\n---- Test tool ----"
npm install
2022-12-21 00:25:29 -05:00
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "npm install prettier + plugin-xml installation error."
2022-12-21 00:25:29 -05:00
exit 1
fi
sudo ln -fs /usr/local/bin/lessc /usr/bin/lessc
if [ ${EL_INSTALL_NGINX} = "True" ]; then
echo -e "\n---- Installing nginx ----"
sudo apt install nginx -y
2022-12-21 00:25:29 -05:00
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "apt install nginx installation error."
exit 1
fi
fi
#--------------------------------------------------
# Install Wkhtmltopdf if needed
#--------------------------------------------------
[IMP] script qemu: support arm64/aarch64 (+ archi native marquée d'un *) Ajoute l'architecture arm64 (aarch64) au déploiement, en plus d'amd64 (x86_64) et s390x. Disponibilité réelle vérifiée (juillet 2026) : - arm64 : Ubuntu, Debian, Fedora (Arch : pas d'image cloud aarch64 -> rejet). - s390x : Ubuntu seulement (inchangé). deploy_qemu.py : - host_arch() : arch native de l'hôte ; toute arch différente est ÉMULÉE (TCG, --virt-type qemu) — plus de liste FOREIGN_ARCHES figée. - virt_install : arm64 -> --arch aarch64 --machine virt --boot uefi (firmware AAVMF résolu par libvirt) ; s390x inchangé ; x86 UEFI/OVMF inchangé. - ensure_emulator(arch) généralisé : installe qemu-system-aarch64 + firmware UEFI AAVMF (arm64) ou qemu-system-s390x (s390x), selon le gestionnaire de paquets, avec vérif de présence (binaire + firmware pour arm64). - Validation --arch tôt via ARCH_DISTRO_SUPPORT (message clair si la distro ne publie pas l'arch). Les URLs d'images arm64 marchent déjà via les alias (fedora/arch aarch64 ; ubuntu/debian arm64). todo.py : menus d'architecture (VM unique + infra) proposent amd64/arm64/ s390x selon la distro ; l'architecture NATIVE de l'hôte est marquée d'un * (défaut) ; les autres sont signalées « émulé, lent ». Le catalogue infra est restreint aux distros publiant l'arch choisie (arm64 -> ubuntu/debian/fedora, s390x -> ubuntu). install_debian_dependency.sh : wkhtmltopdf (deb amd64 en dur) ignoré best-effort sur toute arch non-x86_64 (au lieu d'avorter l'install). Validé : dry-runs Ubuntu/Debian/Fedora arm64 (bonnes URLs + virt-install aarch64/virt/uefi/qemu), rejet Arch arm64, non-régression s390x, menus et filtrage simulés (natif *, arm64 par distro). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-28 03:56:20 -04:00
if [ "$(uname -m)" != "x86_64" ]; then
# WKHTMLTOX_X64 pointe vers un .deb amd64 : sur toute autre architecture
# (s390x, arm64/aarch64…) gdebi échouerait. On saute proprement plutôt que
# d'avorter tout l'install (wkhtmltopdf est optionnel).
echo "wkhtmltopdf : pas de build pour $(uname -m), ignoré (optionnel)."
elif [ ${EL_INSTALL_WKHTMLTOPDF} = "True" ]; then
echo -e "\n---- Installing wkhtml ----"
2022-12-21 00:25:29 -05:00
INSTALLED=$(dpkg -s wkhtmltox | grep installed)
if [ "" == "${INSTALLED}" ]; then
2022-12-21 00:25:29 -05:00
echo -e "\n---- Install wkhtml and place shortcuts on correct place ----"
_url=${WKHTMLTOX_X64}
sudo wget ${_url}
sudo gdebi --n $(basename ${_url})
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "gdebi install wkhtmltopdf installation error."
exit 1
fi
sudo ln -fs /usr/local/bin/wkhtmltopdf /usr/bin
sudo ln -fs /usr/local/bin/wkhtmltoimage /usr/bin
else
echo -e "\n---- Already installed wkhtml ----"
fi
else
echo "Wkhtmltopdf isn't installed due to the choice of the user!"
fi