#!/bin/bash # mage upgrade # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mageupgrade.sh,v 1.8 2005-06-01 15:50:56 niro Exp $ # some default vars : ${MLIBDIR=/usr/lib/mage} : ${DEBUG=false} : ${AUTOANSWER=false} : ${SRCINSTALL=false} source /etc/mage.rc source ${MLIBDIR}/mage3.functions.sh source /etc/init.d/functions unset UPGRADE_LIST unset PLEASE_VALIDATE echo "Fetching list of all installed packages ..." # 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 &> /dev/null #compare them if [[ $(basename ${HIGHEST_MAGEFILE} .mage) > ${PNAME}-${PVER}-${PBUILD} ]] then UPGRADE_LIST="${UPGRADE_LIST} ${PNAME}" SHOW_LIST="${SHOW_LIST}:${PCAT}/${PNAME},[${PVER}-${PBUILD} -> $(basename ${HIGHEST_MAGEFILE#${HIGHEST_MAGEFILE%-*-*}-} .mage)]" 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 # show the list echo echo "Packages selected for upgrade:" OLDIFS="${IFS}" IFS=: for package in ${SHOW_LIST} do # nice output :) echo -en \\033[10G echo -en ${COLGREEN}"$(echo ${package} | cut -d',' -f1)"${COLDEFAULT} echo -en \\033[40G echo -e ${COLBLUE}"$(echo ${package} | cut -d',' -f2)"${COLDEFAULT} done IFS="${OLDIFS}" 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 if [[ ${SRCINSTALL} = false ]] then /sbin/mage install ${package} || exit 1 else /sbin/mage srcinstall ${package} || exit 1 fi 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." if [ -n "${PLEASE_VALIDATE}" ] then 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 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