#!/bin/bash # mage upgrade # some default vars : ${MLIBDIR=/usr/lib/mage} : ${DEBUG=false} : ${AUTOANSWER=false} source /etc/mage.rc source ${MLIBDIR}/mage3.functions.sh unset UPGRADE_LIST unset PLEASE_VALIDATE # get list for directory in ${INSTALLDB}/* do # supress virtuals and fake packages or files x=$(basename ${directory}) if [ ${x} = fake ] || [ ${x} = virtual ] || [ ${x} = virtuals ] || [ ${x} = virtuals.old ] || [ ! -d ${directory} ] then continue fi for package in ${directory}/* do x=$(basename ${package}) PNAME=${x%-*-*} PVER=$(echo ${x#${PNAME}-}| cut -d- -f1) PBUILD=$(echo ${x#${PNAME}-}| cut -d- -f2) PCAT=$(basename $(dirname ${package})) # check if there is any higher version in mage db #needed packages may have ben renamed ?? if [ -d ${MAGEDIR}/${PCAT}/${PNAME} ] then CATEGORIE=${PCAT} MAGENAME=${PNAME} get_highest_magefile #compare them if [[ $(basename ${HIGHEST_MAGEFILE} .mage) > ${PNAME}-${PVER}-${PBUILD} ]] then UPGRADE_LIST="${UPGRADE_LIST} ${PNAME}" else # put them only on PLEASE_VALIDATE if they are not the same package if [[ $(basename ${HIGHEST_MAGEFILE} .mage) != ${PNAME}-${PVER}-${PBUILD} ]] then echo "Not added: ${PNAME}-${PVER}-${PBUILD} is newer than $(basename ${HIGHEST_MAGEFILE} .mage)." PLEASE_VALIDATE="${PLEASE_VALIDATE} ${PNAME}-${PVER}-${PBUILD}" fi fi fi #unset some vars for shure unset x unset PNAME unset PVER unset PBUILD unset PCAT unset CATEGORIE unset MAGENAME unset HIGHEST_MAGEFILE done done unset package directory echo echo "I'm now ready to upgrade your system." echo "Press any key to continue or [CTRL-C] to abort ..." echo read #now run the update for package in ${UPGRADE_LIST} do /sbin/mage install ${package} || exit 1 if [[ ${DEBUG} = true ]] then echo "Installation of ${package} completed." echo "Press any key to continue ..." read fi if [[ ${AUTOANSWER} = true ]] then yes | MAGE_UNINSTALL_TIMEOUT=0 /sbin/mage uninstall ${package} || exit 1 else MAGE_UNINSTALL_TIMEOUT=0 /sbin/mage uninstall ${package} || exit 1 fi if [[ ${DEBUG} = true ]] then echo "Uninstallation of ${package} completed." echo "Press any key to continue ..." read fi #resource /etc/profile source /etc/profile done echo "The system upgrade is now complete." echo -n "Would you like to see the list of ignored packages ? [ y/n ] " read answer if [[ ${answer} = y ]] then echo for i in ${PLEASE_VALIDATE} do echo "avoided: ${i}" done fi echo echo "Please remember to run etc-update to update your config files." echo "You should also source /etc/profile or re-login to your shell." echo