--- trunk/mage/usr/lib/mage/depwalker.sh 2005/09/09 16:35:46 226 +++ trunk/mage/usr/lib/mage/depwalker.sh 2005/09/09 17:50:03 231 @@ -1,7 +1,7 @@ #!/bin/bash #depwalker -# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/depwalker.sh,v 1.1 2005-09-09 16:35:27 niro Exp $ +# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/depwalker.sh,v 1.2 2005-09-09 17:50:03 niro Exp $ # default die function die() @@ -10,24 +10,25 @@ exit 1 } -# # include all needed files -# [ -f ${MLIBDIR}/conf/mage.rc.global ] && \ -# source ${MLIBDIR}/conf/mage.rc.global || \ -# die "${MLIBDIR}/conf/mage.rc.global missing" -# -# [ -f /etc/mage.rc ] && source /etc/mage.rc || \ -# die "Your /etc/mage.rc is missing. Aborting." -# -# [ -f ${MLIBDIR}/mage.functions.sh ] && \ -# source ${MLIBDIR}/mage.functions.sh || \ -# die "mage functions missing" +# include all needed files +[ -f ${MLIBDIR}/conf/mage.rc.global ] && \ + source ${MLIBDIR}/conf/mage.rc.global || \ + die "${MLIBDIR}/conf/mage.rc.global missing" + +[ -f /etc/mage.rc ] && source /etc/mage.rc || \ + die "Your /etc/mage.rc is missing. Aborting." + +[ -f ${MLIBDIR}/mage.functions.sh ] && \ + source ${MLIBDIR}/mage.functions.sh || \ + die "mage functions missing" # for tests only -source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage.rc.global -source /etc/mage.rc -source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh +# source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage.rc.global +# source /etc/mage.rc +# source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh +# MLIBDIR=/home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage -# not serios if missing, only for colors +# not serious if missing, only needed for colors [ -f /etc/init.d/functions ] && source /etc/init.d/functions # disable colors if wanted @@ -53,7 +54,8 @@ echo " -v --pver version number of the package" echo " -b --pbuild build number of the package" echo " -m --method which calc method should be used:" - echo " install srcinstall depend srcdepend" + echo " install, srcinstall, depend, srcdepend" + echo " upgrade, srcupgrade" echo echo "method,name, version and build must be given !" echo @@ -115,7 +117,10 @@ MY_DEPEND="${DEPEND}" # for srcinstall & srcdepend only; SDEPEND also needed - if [[ ${METHOD} = srcinstall ]] || [[ ${METHOD} = srcpretend ]] + if [[ ${METHOD} = srcinstall ]] || \ + [[ ${METHOD} = srcpretend ]] || \ + [[ ${METHOD} = srcupgrade ]] || \ + [[ ${METHOD} = srcuppretend ]] then # only if SDEPEND is not zero if [ -n "${SDEPEND}" ] @@ -169,20 +174,51 @@ # maybe later ? #[ -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] && exit 3 -[[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] && \ +[[ ${METHOD} = pretend ]] || \ + [[ ${METHOD} = srcpretend ]] || \ + [[ ${METHOD} = uppretend ]] || \ + [[ ${METHOD} = srcuppretend ]] && \ echo -n "Calculating dependencies ... " -# get dependencies the package -rumwandern ${MAGEFILE} -[[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] && echo "done" +if [[ ${METHOD} = upgrade ]] || \ + [[ ${METHOD} = srcupgrade ]] || \ + [[ ${METHOD} = uppretend ]] || \ + [[ ${METHOD} = srcuppretend ]] +then + INSTDEPS="$(${MLIBDIR}/magequery.sh -i)" + for dep in ${INSTDEPS} + do + PCAT="$(magename2pcat ${dep} installdb)" + PNAME="$(magename2pname ${dep})" + PVER="$(magename2pver ${dep})" + PBUILD="$(magename2pbuild ${dep})" + + # fake a mage file + MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage" + + rumwandern ${MAGEFILE} + done +else + # get dependencies the package + rumwandern ${MAGEFILE} + + # now add the package itself to the dependencies + ALLDEPS="${ALLDEPS} ${MAGEFILE}" +fi +[[ ${METHOD} = pretend ]] || \ + [[ ${METHOD} = srcpretend ]] || \ + [[ ${METHOD} = uppretend ]] || \ + [[ ${METHOD} = srcuppretend ]] && \ + echo "done" -# now add the package itself to the dependencies -ALLDEPS="${ALLDEPS} ${MAGEFILE}" ## show output of pretend -if [[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] +if [[ ${METHOD} = pretend ]] || \ + [[ ${METHOD} = srcpretend ]] || \ + [[ ${METHOD} = uppretend ]] || \ + [[ ${METHOD} = srcuppretend ]] then # this is a little bit faster declare -i x=0 @@ -212,7 +248,11 @@ fi ## return output from src/install deps -[[ ${METHOD} = install ]] || [[ ${METHOD} = srcinstall ]] && echo "${ALLDEPS}" +[[ ${METHOD} = install ]] || \ + [[ ${METHOD} = srcinstall ]] || \ + [[ ${METHOD} = upgrade ]] || \ + [[ ${METHOD} = srcupgrade ]] && \ + echo "${ALLDEPS}" # delete ${BUILDDIR}/virtuals if exists as not needed anymore #[ -d ${BUILDDIR}/virtuals ] && rm -rf ${BUILDDIR}/virtuals