implemented patchfile and pre post action of package manager, renamed pkgrem -> pkgrm
This commit is contained in:
156
lib/pkgman.sh
156
lib/pkgman.sh
@@ -29,11 +29,15 @@ pkginst()
|
||||
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
|
||||
@@ -46,14 +50,16 @@ export -f pkginst
|
||||
pkgupgd()
|
||||
{
|
||||
prnt I "Application de la mise à jours du système..."
|
||||
exec_preupgd
|
||||
$PKG_MAN $COM_UPGRADE
|
||||
exec_postupgd
|
||||
}
|
||||
export -f pkgupgd
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Uninstallation
|
||||
pkgrem()
|
||||
pkgrm()
|
||||
{
|
||||
prnt I "Désinstallation de paquets..."
|
||||
if [[ $# -lt 1 ]]; then
|
||||
@@ -61,25 +67,167 @@ pkgrem()
|
||||
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 pkgrem
|
||||
export -f pkgrm
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
pkgautorem()
|
||||
pkgautorm()
|
||||
{
|
||||
prnt I "Désinstallation de paquets superflus..."
|
||||
exec_preautorm
|
||||
$PKG_MAN $COM_AUTOREM
|
||||
exec_postautorm
|
||||
}
|
||||
export -f pkgautorem
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user