# ------------------------------------------------------------------------------ # Package manager integration # This file is part of the init.sh project # Copyright (c) 2019-2021 Geoffray Levasseur # ------------------------------------------------------------------------------ # This file is distributed under 3-clause BSD license. # The complete license agreement can be obtained at: # https://opensource.org/licenses/BSD-3-Clause # ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------ # Upgrade package database pkgupdt() { prnt I "Mise à jour de la liste des paquets..." $PKG_MAN $COM_UPDATE } export -f pkgupdt # ------------------------------------------------------------------------------ # Installation pkginst() { prnt I "Installation de paquets..." if [[ $# -lt 1 ]]; then prnt E "pkginst(): des paramètres sont requis." exit 11 fi if [[ ! $INSTALL_MODE == dev ]]; then exec_preinst $@ $PKG_MAN $COM_INSTALL $@ exec_postinst $@ else local pkg= for pkg in $@; do exec_preinst $pkg $PKG_MAN $COM_INSTALL $pkg exec_postinst $pkg done unset pkg fi } export -f pkginst # ------------------------------------------------------------------------------ # Upgrade pkgupgd() { prnt I "Application de la mise à jours du système..." exec_preupgd $PKG_MAN $COM_UPGRADE exec_postupgd } export -f pkgupgd # ------------------------------------------------------------------------------ # Uninstallation pkgrm() { prnt I "Désinstallation de paquets..." if [[ $# -lt 1 ]]; then prnt E "pkgrem(): des paramètres sont requis." exit 11 fi if [[ ! $INSTALL_MODE == dev ]]; then exec_prerm $@ $PKG_MAN $COM_REMOVE $@ exec_postrm else local pkg= for pkg in $@; do exec_prerm $pkg $PKG_MAN $COM_REMOVE $pkg exec_postrm done uset pkg fi } export -f pkgrm # ------------------------------------------------------------------------------ # Cleanup pkgautorm() { prnt I "Désinstallation de paquets superflus..." exec_preautorm $PKG_MAN $COM_AUTOREM exec_postautorm } export -f pkgautorm # ------------------------------------------------------------------------------ # Execute preinstallation code exec_preinst() { local cmd=$(echo $GET_INSTALLLIST | sed "s/@pkg@/$@/") local pkglist=$($cmd) unset $cmd for pkg in $pkglist; do if [[ $(function_exists preinst_$pkg) ]]; then prnt I "Exécution de la préinstallation de $pkg ..." preinst_$pkg fi done export POSTINSTLIST=$pkglist unset pkglist } export -f exec_preinst # ------------------------------------------------------------------------------ # Execute postinstallation code exec_postinst() { if [[ -z $POSTINSTLIST ]]; then return 0 fi for pkg in $POSTINSTLIST; do if [[ $(function_exists postinst_$pkg) ]]; then prnt I "Exécution de la postinstallation de $pkg ..." postinst_$pkg fi done unset POSTINSTLIST } export -f exec_postinst # ------------------------------------------------------------------------------ # Execute preremove code exec_prerm() { local cmd=$(echo $GET_REMOVELIST | sed "s/@pkg@/$@/") local pkglist=$($cmd) unset $cmd for pkg in $pkglist; do if [[ $(function_exists prerm_$pkg) ]]; then prnt I "Exécution du préretrait de $pkg ..." prerm_$pkg fi done export POSTRMLIST=$pkglist unset pkglist } export -f exec_prerm # ------------------------------------------------------------------------------ # Execute postremove code exec_postrm() { if [[ -z $POSTRMLIST ]]; then return 0 fi for pkg in $POSTRMLIST; do if [[ $(function_exists postrm_$pkg) ]]; then prnt I "Exécution de la postretrait de $pkg ..." postrm_$pkg fi done unset POSTRMLIST } export -f exec_postrm # ------------------------------------------------------------------------------ # Execute preupgrade code exec_preupgd() { local pkglist=$($GET_UPGRADELIST) for pkg in $pkglist; do if [[ $(function_exists preupgd_$pkg) ]]; then prnt I "Exécution de la pré mise à jour de $pkg ..." preupgd_$pkg fi done export POSTUPGDLIST=$pkglist unset pkglist } export -f exec_preupgd # ------------------------------------------------------------------------------ # Execute postupgrade code exec_postupgd() { if [[ -z $POSTUPGDLIST ]]; then return 0 fi for pkg in $POSTUPGDLIST; do if [[ $(function_exists postupgd_$pkg) ]]; then prnt I "Exécution de la post mise à jour de $pkg ..." postupgd_$pkg fi done unset POSTUPGDLIST } export -f exec_postupgd # ------------------------------------------------------------------------------ # Execute prerm code in autoremove context exec_preautorm() { local pkglist=$($GET_AUTOREMLIST) for pkg in $pkglist; do if [[ $(function_exists prerm_$pkg) ]]; then prnt I "Exécution du préretrait de $pkg ..." prerm_$pkg fi done export POSTRMLIST=$pkglist unset pkglist } export -f exec_preautorm # ------------------------------------------------------------------------------ # Execute postrm code in autoremove context exec_postautorm() { exec_postrm } export -f exec_postautorm # EOF