#!/bin/bash BUILDSERVER_CACHE_DIR="/var/cache/mage-buildserver" DEBUG=0 if [ -f /etc/rc.d/init.d/functions ] then source /etc/rc.d/init.d/functions else die "/etc/rc.d/init.d/functions not found" fi if [ -f /etc/mage.rc.global ] then source /etc/mage.rc.global else die "/etc/mage.rc.global not found" fi if [ -f /etc/mage.rc ] then source /etc/mage.rc else die "/etc/mage.rc not found" fi if [ -f ${MLIBDIR}/mage4.functions.sh ] then source ${MLIBDIR}/mage4.functions.sh else die "${MLIBDIR}/mage4.functions.sh not found" fi if [ -f ${MLIBDIR}/smage2.functions.sh ] then source ${MLIBDIR}/smage2.functions.sh else die "${MLIBDIR}/smage2.functions.sh not found" fi # do this at least of all includes to prevent path overwrites env-rebuild source /etc/profile # export default path export PATH="${PATH}:${MLIBDIR}" die() { echo "ERROR: $@" exit 1 } is_split_target_magefile() { local mage="$1" for target_mage in ${MY_SPLIT_TARGET_MAGEFILES} do if [[ ${mage} = ${target_mage} ]] then return 0 fi done return 1 } load_mage_features mage_setup if [ ! -d ${BUILDSERVER_CACHE_DIR}/protected ] then die "${BUILDSERVER_CACHE_DIR}/protected directory not found." fi UNINSTALL_PKGS="" for pkg in $(magequery -i) do pname="$(magename2pname ${pkg})" if [ -f ${BUILDSERVER_CACHE_DIR}/protected/${pname} ] then [[ ${DEBUG} = 0 ]] || echo "'${pname}' is protected, ignored." >&2 else magefile=$(get_uninstall_candidates --pname "${pname}") UNINSTALL_PKGS+=" ${magefile}" fi done echo echo "---- dependencies ----" echo "UNINSTALL_PKGS:" for pkg in ${UNINSTALL_PKGS} do echo " * ${pkg}" done echo "----------------------" # now uninstall the packages if [[ -z ${UNINSTALL_PKGS} ]] then echo "Nothing found to uninstall" else uninstall_packages ${UNINSTALL_PKGS} || die "uninstalling packages" ## always run auto etc-update echo "running etc-update" echo "-5" | etc-update fi